我有两个我不明白的问题,希望有人能提供帮助。
此代码不适用于从拆分视图控制器获取我现有的 UINavigationController 层次结构并使用它接管屏幕。我只是得到一个黑屏
UINavigationController* myself = self.navigationController;
[myself removeFromParentViewController];
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"QuestionnaireViewController"];
[myself pushViewController:controller animated:YES];
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
app.window.rootViewController = myself;
但是,此代码确实有效。为什么我可以将 rootViewController 设置为新的 UINavigationController 而不是 self.navigationController?
UINavigationController *navController = [[UINavigationController alloc] init];
UINavigationController* myself = self.navigationController;
[myself removeFromParentViewController];
navController.viewControllers = myself.viewControllers;
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"QuestionnaireViewController"];
[navController pushViewController:controller animated:YES];
AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication] delegate];
app.window.rootViewController = navController;
我的第二个问题是当用户“返回”时将导航控制器恢复到 splitViewController。我从经验中知道我可以将新的 UINavigationController 分配给 detailView,但我无法分配 self.navigationController。
我认为这些问题是同一个问题。由于某种原因,新的 UINavigationController 与 UIView 的 navigationController 不同。为什么?