我正在尝试在标签栏应用程序中制作带有 Storyboard 的向下钻取表。
我在锻炼时遇到问题 如何让主表中的每一行指向其他不同的表。
这是我用来检测行选择的代码。
-(void)tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *__strong)indexPath {
TableViewController *table = [self.storyboard instantiateViewControllerWithIdentifier:@"table"];
[self.navigationController pushViewController:table animated:YES];
}
请问我该如何进行?
最佳答案
UIStoryBoards 真正的美在于 segues。
1.您可以将一个原型(prototype)单元推送segue链接到另一个不同的表格 View Controller
2. 您可以将一个原型(prototype)单元 push segue 循环链接回其自身以进行深入研究。
[self performSegueWithIdentifier:@"segueID" sender:MyObject];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([segue.identifier isEqualToString:@"segueID"]) segue.destinationViewController.chosenCell = sender;
}
如果 segue 来自单元格单击,则发送者是单元格的发送者,您可以从表中获取它的索引路径,并将新信息传递给即将到来的 View Controller 。
如果您希望单元格在单击时采用各种路径,请保留 didSelectRowAtIndexPath 并调用 performSegueWithIndetifier 以便您可以选择左或右。
教程:http://jleeiii.blogspot.com/2012/05/uistoryboard-power-drill-batteries.html
GitHub:http://www.github.com/jllust/UIStoryboardExamples
关于xcode - 在 Storyboard 中向下钻取 tableview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8683141/