本文介绍了如何在 prepareForSegue 中获取索引路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"Action"])
{
NSIndexPath *indexPath = [self.tbl indexPathForSelectedRow];
SecondViewController *destViewController = segue.destinationViewController;
destViewController.getString = [getArray objectAtIndex:indexPath.row];
}
}
我想访问选定的行 index
,但为每个选定的行显示 null
.请帮帮我?
i wanna to access the selected row index
,but show null
for every selected row. please help me?
推荐答案
Swift 3.0/iOS 10
Swift 3.0 / iOS 10
tableView.indexPathForSelectedRow
是在 iOS 9 中引入的
tableView.indexPathForSelectedRow
was introduced in iOS 9
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let indexPath = tableView.indexPathForSelectedRow{
let selectedRow = indexPath.row
let detailVC = segue.destination as! ParkDetailTableVC
detailVC.park = self.parksArray[selectedRow]
}
}
这篇关于如何在 prepareForSegue 中获取索引路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!