与TabBarController一起使用时,不会显示NavigationController

时间:2010-11-12 10:11:45

标签: iphone objective-c uinavigationcontroller ios4 uitabbarcontroller

在我的iphone应用程序中,我有一个导航控制器和一个tabBar控制器。

TabBarController有三个选项卡。在第二个和第三个Tab中,NavigationController被添加到viewControllers中。

问题:

在第三个选项卡中,viewController显示NavigationBar,但第二个选项卡viewController不显示navigationBar。

我尝试过并检查过的事情:

1)我检查了IB中的所有连接是否正确完成

2)我检查了视图的框架大小。它与navigationBar不重叠。

3)我也尝试过使用 self.navigationController.navigationBar.hidden = NO;

但它仍然没有在第二个标签中显示navigationBar。

我该怎么办?

请建议

请帮助

谢谢!

3 个答案:

答案 0 :(得分:0)

如果不查看代码,我们就无法做多少。

假设您的TabBarController已在Interface Builder中正确连接,您将需要类似于此的内容:

UIViewController *firstView = [[UIViewController alloc] init];
UIViewController *secondView = [[UIViewController alloc] init];
UIViewController *thirdView = [[UIViewController alloc] init];

UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:secondView];
UINavigationController *secondNav = [[UINavigationController alloc] initWithRootViewController:thirdView];

self.tabBarController.viewControllers = [NSArray arrayWithObjects:firstView, firstNav, secondNav, nil];

当然,之后发布的所有观点都会发布。

答案 1 :(得分:0)

嗯,这也是我面临的一个问题。

如果你查看你的IB文件,你会发现你可以做一些调整并实现它。 我会在有空的时候发布详细信息。

答案 2 :(得分:0)

糟糕!!!我的一个大错误。我没有在导航控制器的检查器中选中“显示导航栏”的复选框。希望这有助于某人。

相关问题