-6

可能重复:
带有导航控制器的标签栏应用程序

我的 Xcode 版本是 4.3.2。我想在基于标签栏的应用程序中添加导航栏。

谢谢

4

2 回答 2

4

在您的applicationDidFinishLaunching方法中,您可以看到类似

FirstViewController *firstViewController = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
.
.
.   

self.tabBarController = [[UITabBarController alloc] init];
self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstViewController, secondViewController, nil];

将对象添加FirstViewControllerUINavigationController对象如下

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

于 2012-08-17T10:23:37.660 回答
4

例如,您可以使用情节提要来制作它。

ss

于 2012-08-17T10:18:07.120 回答