我有一个导航控制器,它的根视图控制器是一个标签栏控制器。 在这个标签栏控制器中,我有两个视图控制器,像这样:
在标签栏控制器中,我有一个自定义导航栏。 当我点击标签栏中的第一项时,导航栏看起来不错,但是当我点击第二项时,我遇到了一个问题:导航栏下方有另一个红色的导航栏。 有人可以解释这一点吗?
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!!
更多推荐
发布评论