简体   繁体   中英

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 ! 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!!

You can do navigationController.navigationBarHidden = true on the root navigation controller, or the child whatever suits you.

But the better will be if you use only one UINavigationController , and IMO navigationController of UITabBarController only.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM