所以我有一个UITableView,并且单元格连接到UIStoryboardSegue以便打开一个新的UIViewController.单击一个单元格后,准备调用getSse,并且一切正常.
问题:在下面的方法中,我怎么知道TableView中所选单元格的indexPath是什么?
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { ObjectDetailViewController *mvc = [segue destinationViewController]; // PassingObject *obj = [self.array objectAtIndex: ? ]; mvc.passingObject = obj; }
解决方法
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Assume self.view is the table view NSIndexPath *path = [self.tableView indexPathForSelectedRow]; DetailObject *detail = [self detailForIndexPath:path]; [segue.destinationViewController setDetail:detail]; }