How to find indexPath for tapped button in tableView Using Seque

后端 未结 3 570
别那么骄傲
别那么骄傲 2020-12-05 09:16

I have a UITableView using prototype cell.

The cells have a UIButton that show a UIViewController (Modal) using Segue

3条回答
  •  死守一世寂寞
    2020-12-05 09:26

    Very simple solution, if you want to point to the same segue of the selected cell.

    - (IBAction)buttonPressed:(id)sender {
    
        CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tableView];
        NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition];
    
        [self tableView:self.tableView didSelectRowAtIndexPath:indexPath];
    
    }
    

提交回复
热议问题