创建 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
这有意义吗?