我使用2个UITableViews和一个UIViewController实现了一个splitview。用它们自己的数据在屏幕上显示两者都很好。现在,在我的DidSelectRowForIndexPath中,我做了以下操作:
DetailViewController *nextController = [[DetailViewController alloc] initWithStyle:UITableViewStylePlain];
NSMutableArray *objects;
objects = [[NSMutableArray alloc] initWithObjects:@"A", @"B", nil];
nextController.title = @"Filter";
[nextController SetArray:objects];
UINavigationController *nc = [[UINavigationController alloc] initWithRootViewController:nextController];
[self presentModalViewController:nc animated:YES];
//used this before [self.navigationController pushViewController:nextController animated:YES];
[FilterView deselectRowAtIndexPath:indexPath animated:YES];
- 也许你知道一个比我展示nextController更好的方法
- nextController总是从底部显示并移动到顶部。如何完成局部视图从右侧进入视图的默认滑动动画
如果您在创建项目时从master/detail模板启动了应用程序。然后,它将在appDelegate didFinishLaunching
方法中自动设置导航控制器,因此在didSelect
方法中,您只需使用
`[self.navigationController pushViewController:vc animated:YES];`
而不是
[self presentModalViewController:nc animated:YES];
下面是一个示例代码,它使用带有到根视图和从根视图导航的拆分视图。
首先,您需要确认您的基础上有UINavigationController,然后您可以推送ViewController:nextController
[FilterView deselectRowAtIndexPath:indexPath animated:YES];
DetailViewController *nextController = [[DetailViewController alloc] initWithStyle:UITableViewStylePlain];
NSMutableArray *objects;
objects = [[NSMutableArray alloc] initWithObjects:@"A", @"B", nil];
nextController.title = @"Filter";
[nextController SetArray:objects];
[self.navigationController pushViewController:nextController animated:YES];