Hi,
I am seeing a strange behaviour when using a UIButton within a UItableViewCell. When the button is clicked, the event is being called multiple times. Here is the code that I am using, when I ran this in debug with a breakpoint at cell.Tag = indexPath.Row, it hit the breakpoint multiple times on the button click. Any ideas why this is happening?
namespace Test.UI.iOS { public class VZRESMainTableViewDataSource : UITableViewDataSource { public VZRESMainTableViewDataSource () { }
public override int RowsInSection (UITableView tableView, int section)
{
if (VZWorkManagementViewModel.Instance.ResourceList != null) {
return VZWorkManagementViewModel.Instance.ResourceList.Count;
}
return 0;
}
public override int NumberOfSections (UITableView tableView)
{
return 1;
}
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
VZRESMainTableViewCell cell;
NSString reuseIdentifier = new NSString ("ResourceCell");
try
{
cell = (VZRESMainTableViewCell)tableView.DequeueReusableCell(reuseIdentifier, indexPath);
cell.btnTimeEntry.TouchUpInside += (object sender, EventArgs e) => {
/*test code*/ cell.Tag = indexPath.Row;
};
return cell;
}
catch {
cell = new VZRESMainTableViewCell (IntPtr.Zero);
return cell;
}
}
}
}
Thanks Ajay