Embedding a navigation controller in a container -

2019-06-13 05:20发布

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

3条回答
孤傲高冷的网名
2楼-- · 2019-06-13 05:44

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;
查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-06-13 05:52

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.

查看更多
走好不送
4楼-- · 2019-06-13 05:54

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:

enter image description here

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];
查看更多
登录 后发表回答