简体   繁体   中英

UINavigationController Title(s) and buttons are not displayed within UITabBarController

Im having difficulty getting the titles of the navigation bars to display along with the buttons within my tabBarController interface. Im creating the tabBarController programmatically. Here is the screenshot for reference. 在此处输入图片说明

I have tried putting self.navigationController.navigationBarHidden = YES; within the alloc/init method of the tabBarController which is allocated in the appDelegate and set as the windows rootViewController. I've also tried to set its title with this code self.navigationController.title = [[self.viewControllers objectAtIndex:self.selectedIndex]title ]; . I have also tried using the same code within the viewDidLoad method of my tabBarController class. Within the UITabBarController's alloc/init method I do have this code to set the nav controllers that I have added to the viewControllers array.

UINavigationController *nav2 = [[UINavigationController alloc]initWithRootViewController:contactsTblView];
        nav2.title = @"Contacts";
        nav2.navigationItem.title = @"Contacts";
        nav2.tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemContacts tag:2];
        nav2.delegate = self ;

The title that appears in the navigation bar is the title of the currently showing view controller (the top of the navigation controller's stack). You should set the title of the individual view controllers embedded in the navigation controller, not the navigation controller itself.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM