xcode - 在 Storyboard 中向下钻取 tableview

标签 xcode uitableview

我正在尝试在标签栏应用程序中制作带有 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/

相关文章:

swift - 从字典 Swift 2 随机生成属性

iphone - 如何将重复背景图像设置为表格单元格

ios - handleKeyboardWillShow 通知处理

iphone - 将 UITextField 添加到 UITableViewCell

Xcode 7.1 - Storyboard中的原型(prototype)单元格未显示

iphone - 将代码提交到 SVN 服务器时更改工作副本路径。

ios - 转到另一个 Storyboard,但导航 Controller 仍然可见

ios - 从 Swift 1.2 转换为 2 - 变量函数

iphone - 使用我的主 iPhone 进行 SDK 开发有什么问题吗?

ios - 滚动 UITableView 后 UIActivityIndi​​catorView 不出现