Navigation Controller Header is not showing

2019-09-10 04:55发布

问题:

So, here I basically have this layout

but when I build successfully I am not able to see the title of the navigation controller.

What can I do?

回答1:

This is what you want to emulate:

  • Set the UITabBarController as is Initial View Controller
  • add a relationship to each scene, whether it is a UINavigationController or not
  • If a scene is a UINavigationController, it will behave like any root navigation controller, with its own view stack, back button, an so forth.

Running the app above, then tapping on Item 2 will present this navigation controller:


If you cannot make the UITabBarController the initial View Controller at launch, you can make it become root later on using this technique:

let newViewController = self.storyboard?.instantiateViewControllerWithIdentifier("id")
                        as? UIViewController
self.view.window?.rootViewController = newViewController

This will present the architecture above, albeit without animation (nor any way to navigate back). Perfect for onboarding or login screens.


Tested on Xcode 7+, iOS 9+



回答2:

Make your TabBar Controller the initial view, And make sure to remove the navigation controller that's linked to it, Then it should work fine.