Embedding a navigation controller in a container - Objective C

梦想与她 提交于 2019-12-10 12:14:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!