[英]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?
有人可以帮我解释一下吗?
If you don't want navigation bar of first navigation controller then from the interface builder (storyboard) select your root navigation controller (ie navigationcontroller that's embed with tabbarcontroller) and from attribute inspector
uncheck shows navigation bar
under Navigation controller
! 如果您不想使用第一个导航控制器的导航栏,则从界面构建器(storyboard)中选择您的根导航控制器(即,嵌入tabbarcontroller的Navigationcontroller),然后从
attribute inspector
取消选中在Navigation controller
下shows navigation bar
! 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, 就您而言,您应该在
viewWillDisAppear
和viewWillAppear
隐藏并显示导航栏,例如,
In viewWillAppear
在
viewWillAppear
self.navigationController.navigationBar.hidden = NO;
In viewWillDisAppear
在
viewWillDisAppear
self.navigationController.navigationBar.hidden = YES;
Do above things for your both viewcontroller of your tabbarcontroller!! 为您的tabbarcontroller的两个viewcontroller做以上事情!!
You can do navigationController.navigationBarHidden = true
on the root navigation controller, or the child whatever suits you. 您可以在根导航控制器上或适合您的子项上执行
navigationController.navigationBarHidden = true
。
But the better will be if you use only one UINavigationController
, and IMO navigationController
of UITabBarController
only. 但是更好的情况是,如果仅使用一个
UINavigationController
,并且仅使用UITabBarController
IMO navigationController
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.