I’ve got dynamic tableView and one problem. In each tableCell are two buttons.
I’m trying to get indexPath.row on button touched but with no success.
My code:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.homeTableView indexPathForSelectedRow];
NSLog(@"%d", indexPath.row);
}
How can I get indexPath.row for touced button (Segue connections are over this two buttons->two connections)?
It’s not working because you do not select row when you click button.
With two buttons I would disconnect your segues from buttons and do 2 manual segues in IB then add code like that to handle them:
Edit for second option:
In your MyTableViewCell.h:
In your MyTableViewCell.m:
In your MyTableViewController.m: