我正在尝试使用Tab栏应用程序中的故事板制作下钻表.我在解决如何让主表中的每一行指向其他不同的表时遇到问题.
这是我用来检测行选择的代码.
-(void)tableView: (UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *__strong)indexPath {
TableViewController *table = [self.storyboard instantiateViewControllerWithIdentifier:@"table"];
[self.navigationController pushViewController:table animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
Ini*_*son 12
UIStoryBoards真正的美丽是segues.1.您可以将一个原型单元push segue链接到另一个不同的表视图控制器2.您可以将一个原型单元push segue循环链接回自身以进行钻取.
[self performSegueWithIdentifier:@"segueID" sender:MyObject];
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([segue.identifier isEqualToString:@"segueID"]) segue.destinationViewController.chosenCell = sender;
}
Run Code Online (Sandbox Code Playgroud)
如果segue来自单元格单击,则发送方是单元格的发送方,您可以从表中获取它的索引路径,并将新信息传递给即将到来的视图控制器.如果您希望单元格在单击时采用各种路径,请保留didSelectRowAtIndexPath并调用performSegueWithIndetifier,以便您可以选择向左或向右.
教程:http://jleeiii.blogspot.com/2012/05/uistoryboard-power-drill-batteries.html
GitHub:http://www.github.com/jllust/UIStoryboardExamples
| 归档时间: |
|
| 查看次数: |
3326 次 |
| 最近记录: |