0

在我的第一个 iPad 项目上工作,在许多错误的开始之后,我有一个我很满意的基本界面,它包括一个拆分视图控制器,在根/弹出窗口的底部有一个 4 选项卡选项卡栏。

对于 4 个选项卡中的每一个,我都有 4 个不同的视图控制器。其中三个包含表格,第四个包含我的设置滑块和开关。所有这些都适用于纵向或横向。

我面临的挑战是如何从这些不同的选项卡驱动详细视图。我不一定需要多个详细视图,因为所有 3 个表都将引用相同的数据,只是排序不同。所以他们可能都连接到同一个细节视图。

我还没有找到任何其他像这样使用标签栏的例子,但它似乎是我的应用程序的完美解决方案。

如何建立连接,以便当我选择表格单元格时,detailItem 信息会显示在详细信息视图中?选项卡栏已添加到 IB 的根视图中。我应该以编程方式添加它吗?

有没有人有一个示例项目,你已经让它工作了?

谢谢!

4

1 回答 1

0

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

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;

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.

于 2011-02-23T23:29:27.507 回答