Search code examples
iphoneiosxcodeipadios6

TabbedView not displaying the Navigation bar


iOS beginner here. I'm Using XCode 4.6.3 and doing some tutorials. I have a question regarding a TabbedView not displaying the Navigation bar:

I set the Top Bar attribute to "Navigation Bar" here : I set the Top Bar attribute here

But it doesn't show here : But it doesn't show here

Below is the code in the AppDelegate :

self.navController = [[UINavigationController alloc] initWithRootViewController:viewController1];
self.navController.navigationBar.barStyle = UIBarStyleBlack;
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = @[viewController1, viewController2];
self.window.rootViewController = self.tabBarController;

What am I doing wrong?


Solution

  • You have initialized your Navigation Controller with your First View Controller. So, you have to use Navigation Controller for the Tab Bar's View Controllers.

    Change this Line

    self.tabBarController.viewControllers = @[viewController1, viewController2];
    

    With

    self.tabBarController.viewControllers = @[self.navController, viewController2];