![](/img/trans.png)
[英]UINavigationController within a UITabBarController, setting the navigation controller title
[英]UINavigationController Title(s) and buttons are not displayed within UITabBarController
我在获取导航栏标题以及tabBarController界面中的按钮显示时遇到困难。 我以编程方式创建tabBarController。 这是供参考的屏幕截图。
我试过把self.navigationController.navigationBarHidden = YES;
在tabDBargate的alloc / init方法中,该方法在appDelegate中分配并设置为Windows rootViewController。 我还尝试使用此代码设置其标题self.navigationController.title = [[self.viewControllers objectAtIndex:self.selectedIndex]title ];
。 我也尝试过在tabBarController类的viewDidLoad方法中使用相同的代码。 在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 ;
导航栏中出现的标题是当前显示的视图控制器的标题(导航控制器堆栈的顶部)。 您应该设置嵌入在导航控制器中的各个视图控制器的标题,而不是导航控制器本身。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.