添加导航栏的TabBar应用
问题描述:
可能重复:
Tab Bar Application With Navigation Controller添加导航栏的TabBar应用
我的版本的Xcode 4.3.2是。我想在基于tabbar的应用程序中添加导航栏。
谢谢
答
例如,您可以使用故事板。
答
在你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
将被视为导航控制器,并且它将具有导航栏。
编辑
如果你只是想在导航栏上,然后你可以从xib
插入或添加UINavigationBar
在self.view
+1
非常感谢S P Varma。 – Rushabh 2012-08-17 10:28:16
UINavigationBar的*巴子视图; bar.topItem.title = @“First”; – Rushabh 2012-08-17 10:15:15
self.navigationController.navigationItem.title = @“First”; 但两者都不起作用。 – Rushabh 2012-08-17 10:17:04
我的银行号码是XXXCCCYYYZZZ,我想要一百万美元添加到它。 谢谢。 – 2012-08-17 10:27:09