Instead, you should use this method:
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tableView]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition];
Quick version:
let buttonPosition = sender.convert(CGPoint(), to:tableView) let indexPath = tableView.indexPathForRow(at:buttonPosition)
This will give you indexPath depending on the position of the button that was pressed. Then you just call cellForRowAtIndexPath if you need a cell or indexPath.row if you need a row number.
If you are paranoid, you can check if (indexPath) ... before using it, only if indexPath not found for this point in the table view.
All other answers may break if Apple decides to change the presentation structure.
iwasrobbed Apr 29 '13 at 1:58 2013-04-29 01:58
source share