If you use a custom cell accessory instead of the DetailDisclosureButton you can no long use the AccessoryButtonTapped event...how do I use a custom cell accessory (i.e. a UIButton set as the AccessoryView for the cell) and be able to get the NSIndexPath that countains the row and section that was selected?
image = UIImage.FromFile ("Images/checkmark.png");
lockButton = new UIButton(UIButtonType.Custom);
frame = new RectangleF(0f, 0f, 25f, 25f);
lockButton.Frame = frame;
lockButton.SetBackgroundImage(image, UIControlState.Normal);
lockButton.TouchUpInside += (sender, e) =>
{
try{
int i =0;
foreach(UIView sv in cell.Subviews)
{
if(cell.Subviews[i] is UITableView)
;
}
}
catch
{
}
};
if (sourceType == TableSoureType.Collections && collGroup [indexPath.Section].LocationEntity [indexPath.Row].CollectionStatus.ToLower () != "open") {
cell.TextLabel.TextColor = UIColor.Gray;
cell.AccessoryView = lockButton;
}
else if(sourceType == TableSoureType.Collections && collGroup [indexPath.Section].LocationEntity [indexPath.Row].CollectedToday) {
cell.TextLabel.TextColor = UIColor.Black;
cell.AccessoryView = lockButton;
}
else
{
cell.TextLabel.TextColor = UIColor.Black;
cell.Accessory = UITableViewCellAccessory.DetailDisclosureButton;
}
This may be cause for a new post but I also have an issue where when I click the button the application exits on the simulator - I understand that it may be a garbage collection issue so I moved the declaration of my button, image, and frame to the class level to no avail.
So I have two issues:
1 - Once I get the TouchUpInside event to work correctly how do I figure out which cell was selected when that event was fired?
2 - How to get the TouchUpInside event to fire without causing a crash on the simulator - from my understanding its a garbage collection issues - i guess its also important to not that the crash doesn't happen on the device itself...but the code thats in the inside doesn't work either