Haroun SMIDA
Haroun SMIDA

Reputation: 1116

Embedding a navigation controller in a container - Objective C

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

Upvotes: 0

Views: 1389

Answers (3)

Qun Li
Qun Li

Reputation: 1316

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];

Upvotes: 0

ghoshghosh
ghoshghosh

Reputation: 196

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.

Upvotes: 1

3vangelos
3vangelos

Reputation: 511

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;

Upvotes: 0

Related Questions