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

发布于 2024-10-02 19:31:53 字数 466 浏览 0 评论 0原文

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

TabBarController 具有三个选项卡。在第二个和第三个选项卡中,导航控制器被添加到视图控制器中。

问题:

在第三个选项卡视图控制器中显示导航栏,但在第二个选项卡视图控制器中不显示导航栏。

我尝试和检查过的事情:

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

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

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

但它仍然没有在第二个选项卡中显示导航栏。

我应该怎么办?

请大家

帮忙

推荐一下谢谢!!

In my iphone app, i have a navigation Controller and a tabBar Controller.

The TabBarController has three tabs. In the second and third Tab the NavigationController are added to the viewControllers.

Problem :

In third tab viewController shows the NavigationBar but the in second tab viewController doesnot display navigationBar.

Things I have tried and checked:

1) I checked that all the connections in IB are done properly

2) I checked the size of frame for the view. It doesnot overlap the navigationBar.

3) I also tried using self.navigationController.navigationBar.hidden = NO;

But still it does not show the navigationBar in the second tab.

What should I do?

Please Suggest

Please Help

Thanks!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

佞臣 2024-10-09 19:31:53

如果不查看您的代码,我们就无能为力。

假设您的 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];

当然,之后要释放每个视图。

We can't do much without looking at your code.

Assuming your TabBarController is properly connected in Interface Builder, you'll need something similar to this:

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];

Of course, have every view released afterwards.

原来分手还会想你 2024-10-09 19:31:53

嗯,这也是我遇到的问题。

如果您查看 IB 文件,您会发现可以进行一些调整并实现它。
我一有时间就会发布详细信息。

Hmmm thats a problem i faced too.

If you look at your IB file ,you'll see that you can do a bit of tweaking and acheive it.
i'll post details as soon as i get time.

云淡风轻 2024-10-09 19:31:53

哎呀!!!我犯了一个大错误。我没有在 NavigationController 的检查器中选中“显示导航栏”复选框。希望这对某人有帮助。

Oops!!! a big mistake on my part.I did not check the checkbox for "show navigation bar" in inspector for NavigationController. Hope this helps someone.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文