拆分视图控制器根中的选项卡栏 - 如何连接到详细信息视图?
在我的第一个 iPad 项目上工作,经过多次失败后,我有了一个令我满意的基本界面,它由一个分割视图控制器和一个位于根/弹出窗口底部的 4 个选项卡选项卡栏组成。
我为 4 个选项卡中的每一个都有 4 个不同的视图控制器。其中三个包含表格,第四个包含我的设置滑块和滑块。开关。所有这些在肖像或风景中都可以正常工作。
我面临的挑战是如何从这些不同的选项卡驱动详细信息视图。我不一定需要多个详细信息视图,因为所有 3 个表都将引用相同的数据,只是排序不同。因此它们可能都连接到同一个详细视图。
我还没有找到像这样使用选项卡栏的任何其他示例,但这似乎是我的应用程序的完美解决方案。
如何建立连接,以便当我选择表格单元格时,detailItem 信息会显示在详细信息视图中?选项卡栏已添加到 IB 的根视图中。我应该以编程方式添加它吗?
有谁有一个示例项目可以让您实现这一点吗?
谢谢!
working on my first iPad project and after many false starts I have a basic interface that I am happy with that consists of a Split View Controller with a 4-tab Tab Bar at the bottom of the Root/Popover.
I have 4 different View Controllers for each of the 4 tabs. Three of these contain tables, the fourth contains my settings sliders & switches. All this works fine in portrait or landscape.
The challenge I'm facing is how to drive the Detail View from these various tabs. I don't necessarily need multiple Detail Views since all 3 tables will be referencing the same data, just sorted differently. So they could potentially all connect to the same Detail View.
I haven't found any other examples of Tab bars being used like this, but it seems like the perfect solution for my app.
How do I establish a connection so that when I select a table cell, the detailItem info gets displayed in the Detail View? Tab bar was added to the Root View in IB. Should I be adding it programmatically instead?
Does anyone have an example project where you've gotten this to work?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不要太沉迷于“标签栏”部分。考虑一个更简单的应用程序如何工作:如果您在 RootViewController 中选择一个单元格,您将如何通知 DetailViewController?
它不会是自动的。最有可能的是,您将拥有从 RootViewController 到 DetailViewController 的专用连接 - 并且您将从 RootViewController 调用 DetailViewController 上的某些方法,类似于
RootViewController 中的方法。事实上,这就是模板 UISplitView iPad 应用程序的设置方式。有一个从 RootViewController 到 DetailViewController 的 IBOutlet 连接。
只要您正确管理内存(保留、释放) - 如果您的每个(根)视图控制器(在选项卡视图中)都与单个 DetailViewController 有连接,那么就不会有问题。为了防止选项卡式控制器相互干扰,您可能希望将逻辑集中到“中间人”类中。也许您想在 ViewControllerB 对 ViewControllerA 刚刚排序的详细信息进行排序之前清理一些内容......
这部分由您决定。请注意,没有后端黑魔法发生,因此 DetailViewController 会自动更新以显示基于在任何 RootViewController 中选择的单元格的内容。
Don't get too caught up in the 'tabbar' piece of this. Consider how a simpler app would work: if you select a cell in the RootViewController, how would you notify the DetailViewController?
It won't be automatic. Most likely, you will have a dedicated connection from the RootViewController to the DetailViewController - and you will invoke some method on the DetailViewController from the RootViewController in something like the
method in the RootViewController. Indeed, this is how the template UISplitView iPad app is setup. There is an IBOutlet connection from the RootViewController to the DetailViewController.
As long as you manage the memory correctly (retain, release) - there should be no problem if each of your (root) view controllers (in the tab view) have a connection to the single DetailViewController. To keep the tab'd controllers from stepping on each other, you may wish to centralize the logic into a 'middleman' class. Maybe you want to clean something up just before ViewControllerB sorts the details that ViewControllerA just sorted ...
That part is up to you. Just note that there is no backend black magic going on such that a DetailViewController is automatically updated to show something based on a cell selected in any RootViewController.