问题
How to embed a Navigation controller in a container View? When I place the container the first this that shows is a viewController embed to the container, I want to change that viewController to a navigation view and set it rootViewController and other views
回答1:
Basically just add the ViewController into a UINavigationController and set the UINavigationController as your rootViewController. Hope that helps:
ViewController *vc = [[ViewController alloc] init];
UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:vc];
self.window.rootViewController = nvc;
回答2:
If you want to add navigation controller with storyboard then it's very simple, just follow these steps: * select the storyboard to which you want to attach a storyboard, *go to toolbar then, * Editor->Embed In->Navigation controller. *your storyboard automatically embedded with navigation controller.
回答3:
The UINavigationController controls the UIViewController . So the "container" is NavigationController not others.
The same as UITabbarController. If you want to change the view architecture even the rootViewControler. I will tell you my experience.
Like this:
We can switch the login page and homeTabbar container freedom.
if (Boolean conditions) {//show login page
[self showLoginAndRegisterVC];
} else { //show home Page
[self showHomeViewController];
}
[self.window makeKeyAndVisible];
来源:https://stackoverflow.com/questions/36056812/embedding-a-navigation-controller-in-a-container-objective-c