Search code examples
objective-cuinavigationcontrolleruicontainerview

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


Solution

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