2

我无法合并在我的主视图中使用 SplitViewController 和拥有控制左窗格弹出/侧边栏表视图的“RootView”控制器这两个概念。

我想让左侧的“RootView”充当导航菜单,但是当 RootView 通过 MainWindow.xib 绑定​​到 SplitView 的左窗格时,我该怎么做?

基本上,我希望左侧导航能够像内置的电子邮件应用程序文件夹下钻导航一样工作。是否有一个示例 iPad 项目同时使用 SplitView 和 NavigationView 作为左/根窗格?

4

1 回答 1

4

创建 SplitView 项目后,打开 RootViewController.m 文件并查看 -tableViewDidSelectRowAtIndexPath 方法。您将看到您单击的项目随后被设置为 DetailViewController 的属性。

您正在寻找的设计需要您将另一个视图控制器推送到导航堆栈上。因此,如果您想象电子邮件应用程序,当用户选择一个文件夹时,detailView 不会更新,而是将收件箱的下一级推送到堆栈上。当用户从收件箱中选择一条消息时,详细视图将使用消息内容进行更新,而 RootViewController 只是停留在它所在的位置。

在 -tableViewDidSelectRowAtIndexPath 方法中,声明您的新视图控制器

NextViewController *nextView = [[NextViewController alloc] initWithStyle:UITableViewStylePlain];
//This assumes you have another table view controller called NextViewController
//We assign it to the instance variable "nextView"

[self.navigationController pushViewController:nextView animated:YES];
//tells the navigation controller to "slide" the "nextView" instance on top
//if animated:NO it wouldn't slide, it would just "update"

[nextView release];
//release the viewController, it's now retained automatically by the NavigationController

这有意义吗?

于 2010-04-19T15:09:09.240 回答