[英]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. 我在获取导航栏标题以及tabBarController界面中的按钮显示时遇到困难。 Im creating the tabBarController programmatically.
我以编程方式创建tabBarController。 Here is the screenshot for reference.
这是供参考的屏幕截图。
I have tried putting self.navigationController.navigationBarHidden = YES;
我试过把
self.navigationController.navigationBarHidden = YES;
within the alloc/init method of the tabBarController which is allocated in the appDelegate and set as the windows rootViewController. 在tabDBargate的alloc / init方法中,该方法在appDelegate中分配并设置为Windows rootViewController。 I've also tried to set its title with this code
self.navigationController.title = [[self.viewControllers objectAtIndex:self.selectedIndex]title ];
我还尝试使用此代码设置其标题
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.
我也尝试过在tabBarController类的viewDidLoad方法中使用相同的代码。 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.
在UITabBarController的alloc / init方法中,我确实有这段代码来设置我添加到viewControllers数组中的导航控制器。
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.
您应该设置嵌入在导航控制器中的各个视图控制器的标题,而不是导航控制器本身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.