在容器中嵌入导航控制器 - Objective C

Embedding a navigation controller in a container - Objective C

如何在容器视图中嵌入导航控制器? 当我放置容器时,第一个显示的是 viewController 嵌入到容器中,我想将其 viewController 更改为导航视图并将其设置为 rootViewController 和其他视图

基本上只需将 ViewController 添加到 UINavigationController 并将 UINavigationController 设置为您的根 ViewController。希望对您有所帮助:

ViewController *vc = [[ViewController alloc] init];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
self.window.rootViewController = nvc;

如果你想添加带故事板的导航控制器,那很简单,只需按照以下步骤操作: * select 您要附加情节提要的情节提要, *然后转到工具栏, * 编辑器->嵌入->导航控制器。 *你的故事板自动嵌入了导航控制器。

UINavigationController 控制着 UIViewController。所以 "container" 是 NavigationController 而不是其他人。

与UITabbarController相同。如果你想改变视图架构甚至是 rootViewControler。我会告诉你我的经历。

像这样:

我们可以自由切换登录页面和homeTabbar容器。

if (Boolean conditions) {//show login page
    [self showLoginAndRegisterVC];
} else { //show home Page
    [self showHomeViewController];
}
[self.window makeKeyAndVisible];