我正在尝试以编程方式用 SplitViewController 替换当前视图。这是我的代码。
ProjectNavigationController *projectNavPanel = [[ProjectNavigationController alloc] init];
[projectNavPanel setProjectIndex:[indexPath row]];
[projectNavPanel setKuluId:[[[[[appDelegate userSettingsDictionary] objectForKey:@"Projects"] objectAtIndex:[indexPath row]] objectForKey:@"Kulu Id"] intValue]];
ProjectDetailController *projectDetailPanel = [[ProjectDetailController alloc] init];
[projectDetailPanel setProjectIndex:[indexPath row]];
ProjectSplitViewController *splitRootController = [[ProjectSplitViewController alloc] init];
[splitRootController setViewControllers:[NSArray arrayWithObjects:projectNavPanel, projectDetailPanel, nil]];
[[self view] removeFromSuperview];
[[appDelegate window] setRootViewController:splitRootController];
这几乎可以正常工作,但有一个例外。当拆分视图控制器加载并处于纵向模式时,导航视图会隐藏 - 正如预期的那样 - 但详细视图没有带有按钮的工具栏,用于在弹出视图中显示导航。根据我的研究,我知道这是默认行为。我错过了什么吗?detailViewController 中的代码很少,所以我没有在此处包含代码,但如果有帮助,请告诉我。