0

I have created a custom button in UITableView prototype cell and connected it to a ViewController with segue. I want to find the selected row when this button is clicked.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"rowSelected"]) {

        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        DViewController *detailViewController = segue.destinationViewController;
        detailViewController.recipeImage.image = [UIImage imageNamed:[imageTitleArray objectAtIndex:indexPath.row]];
    }
}

But the indexPath is always nil when the button is clicked.

Mike Mertsock
  • 11,825
  • 7
  • 42
  • 75

0 Answers0