嵌入Navigation Controller后导航栏不显示,StackOverflow方案无效求助
Hey there! I’ve run into this exact issue a few times before, so let’s break down the most likely fixes for your missing navigation bar:
Double-check your segue target
A super common mistake is linking theshowsegue directly to the embedded ViewController instead of the Navigation Controller itself. Head back to your Storyboard:- Select the control (like a button) that triggers the segue
- Hold Ctrl and drag to the Navigation Controller (not the ViewController inside it)
- Choose
showfrom the segue options. If you had a previous wrong segue, delete it first.
Check for hidden navigation bar settings
Your navigation bar might be getting hidden accidentally, either in Storyboard or code:- In Storyboard: Select your ViewController, open the Attributes Inspector, and make sure the Hide Navigation Bar checkbox is unchecked.
- In code: Look through your ViewController's
viewDidLoad,viewWillAppear, orviewDidAppearmethods for lines like:
If you find this, either remove it or change the value tonavigationController?.isNavigationBarHidden = truefalse(or adjust it to only hide when needed).
Verify the Navigation Controller's own settings
Sometimes the Navigation Controller itself has its navigation bar disabled. Select your Authentication Storyboard's Navigation Controller, open the Attributes Inspector, and confirm that Shows Navigation Bar is checked (this is the default, but it can get toggled by mistake).Test if segue type is causing unexpected behavior
Whileshowsegue should work fine (it adapts to push on iPhone/popover on iPad), if you’re triggering it from a modally presented ViewController, try switching the segue to Present Modally with Presentation set to Full Screen as a quick test. If the navigation bar shows up then, the issue was likely with how theshowsegue was interacting with the modal context—but the first three fixes are still the most probable culprits.
内容的提问来源于stack exchange,提问作者Agung

