导航控制器与导航控制器的标签栏控制器(Navigation controller with tab bar controller of navigation controller)

编程入门 行业动态 更新时间:2024-10-23 11:30:40
导航控制器与导航控制器的标签栏控制器(Navigation controller with tab bar controller of navigation controller)

我有一个导航控制器,它的根视图控制器是一个标签栏控制器。 在这个标签栏控制器中,我有两个视图控制器,像这样:

在标签栏控制器中,我有一个自定义导航栏。 当我点击标签栏中的第一项时,导航栏看起来不错,但是当我点击第二项时,我遇到了一个问题:导航栏下方有另一个红色的导航栏。 有人可以解释这一点吗?

I have a navigation controller, and its root view controller is a tab bar controller. In this tab bar controller I have two view controllers like this:

In the tab bar controller I have a custom navigation bar. When I click the first item in tab bar, the navigation bar looks good but when I click the second, I have a problem: below the navigation bar there is another navigation bar with red color. Can some explain this for me?

最满意答案

你可以在根控制器或者任何适合你的孩子上做navigationController.navigationBarHidden = true 。

但是,如果仅使用一个UINavigationController ,并且仅使用UITabBarController IMO navigationController ,则效果会更好。

If you don't want navigation bar of first navigation controller then from the interface builder (storyboard) select your root navigation controller (i.e. navigationcontroller that's embed with tabbarcontroller) and from attribute inspector uncheck shows navigation bar under Navigation controller! This will hide navigation bar for root navigation view controller!!

In your case you should hide and show navigation bar in viewWillDisAppear and viewWillAppear something like,

In viewWillAppear

self.navigationController.navigationBar.hidden = NO;

In viewWillDisAppear

self.navigationController.navigationBar.hidden = YES;

Do above things for your both viewcontroller of your tabbarcontroller!!

更多推荐

本文发布于:2023-07-28 19:03:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1308169.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:控制器   标签   Navigation   controller   bar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!