- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我想构建一个应用程序来导航数据层次结构。此层次结构类似于我在下图中显示的结构。结构的一个分支可以比其他分支有更多的层次。
我想像这样使用 TableView 深入了解此结构:
A > AA > AAB > AABA
或
A > AB > ABA
我想知道的是,我是否可以在故事板中只有一个 TableViewController 并重用它来显示每一层新数据?我不想在 Storyboard中将一堆 tableviewcontrollers
链接在一起,因为我不确定我是否会有 3、4 或 100 级的层次结构。
最佳答案
要在 Storyboard中仅绘制一个 VC 来递归到任意深度,请使用 Storyboard绘制顶层:一个导航 Controller ,其根部有一个 TableView Controller 。表 vc 应该是一个 UITableView 子类,并且在 Storyboard 中有一个 Storyboard 标识符(例如,“MyCustomTableVC”)。
为 MyCustomTableVC 提供一个公共(public)属性(例如,ModelItem *node),指示它应该呈现模型中的哪个节点。
当表 vc 获取 didSelectRowAtIndexPath
时,让它创建自己的另一个实例,而不是 Storyboard segues...
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
// Imagine it's called MyCustomTableVC
MyCustomTableVC *newVC = (MyCustomTableVC*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"MyCustomTableVC"];
将 newVC 模型节点设置为所选项目(模型中位于 indexPath.row 的项目),然后推送到它...
// making up a lot of stuff about your model here, but hopefully you get the idea...
newVC.node = [self.model objectAtIndex:indexPath.row];
[self.navigationController pushViewController:newVC animated:YES];
这种方法的好处是可以获得所有导航 Controller 行为:动画按下和弹出、后退按钮等。
关于objective-c - 使用 UITableView 向下钻取分层数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15115637/
运行 apache-drill-1.14.0 在 mysql 上测试这个查询并在 0.02 秒内得到结果 在 drill cli 中运行查询失败并出现 AssertionError 查询: produ
我是 Apache Drill 的新手。 场景是这样的: 我有一个 S3 存储桶,我在其中放置了名为 test.csv 的 csv 文件。 我已经按照官方网站的说明安装了 Apache Drill。
我正忙于学习第 2 版《编程:使用 C++ 的原理与实践》(Stroustrup),并且在读取值时遇到了有无空格的问题,然后再次显示它们。 能否请您指出正确的方向,以便我找出结果不同的原因? 代码编译
我是一名优秀的程序员,十分优秀!