I want to detect button tap on a UITableViewCell where the parent UITableView consists of multiple sections.
I was able to do it in the case of single section, but I
A more direct way to get the index path without using CGPoint and making assumptions about UI is to look at the .superview. I'd imagine this is more reliable in practice.
- (myTableViewCell *)cellContainingView:(UIView *)view
{
do {
view = view.superview;
} while (view != nil && ![view isKindOfClass:[myTableViewCell class]]);
return (myTableViewCell *)view;
}
Then you can simply do this in the button action:
- (IBAction)myButtonPressed:(id)sender
{
myTableViewCell *cell = [self cellContainingView:(UIView *)sender];
NSIndexPath *path = [self.tableView indexPathForCell:cell];
}