在标签栏应用程序中添加导航栏 [重复]
Posted
技术标签:
【中文标题】在标签栏应用程序中添加导航栏 [重复]【英文标题】:Add Navigation Bar in Tabbar Application [duplicate] 【发布时间】:2012-08-13 18:51:09 【问题描述】:可能重复:Tab Bar Application With Navigation Controller
我的 Xcode 版本是 4.3.2。我想在基于标签栏的应用程序中添加导航栏。
谢谢
【问题讨论】:
UINavigationBar *bar; bar.topItem.title = @"第一个"; self.navigationController.navigationItem.title = @"First";但两者都不起作用。 我的银行号码是 XXXCCCYYYZZZ,我想在里面加一百万美元。谢谢。 我很抱歉对 Rocks 的评论,但当我看到这个问题时,我真的想到了这个:D 【参考方案1】:例如,您可以使用故事板来制作。
【讨论】:
【参考方案2】:在您的 applicationDidFinishLaunching
方法中,您可以看到类似
FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
.
.
.
self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstViewController, secondViewController, nil];
将FirstViewController
的对象添加到UINavigationController
对象如下
UINavigationController *firstNavController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
.
.
.
//And in the tabbarController array add the navigationController Object instaed if FirstViewControllerObject
self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstNavController, secondViewController, nil];
它完成了。现在您的FirstViewController
将被视为navigationController 并且将具有导航栏。
编辑
如果您只想要导航栏,那么您可以从xib
插入它或将UINavigationBar
添加为self.view
中的子视图
【讨论】:
非常感谢 S P Varma。以上是关于在标签栏应用程序中添加导航栏 [重复]的主要内容,如果未能解决你的问题,请参考以下文章