My navigation bar is showing up in storyboard but not in the simulator

六眼飞鱼酱① 提交于 2019-12-11 00:48:26

问题


When trying to add a navigation bar for searching on the left button and eventually a setting button on the right bar button, the bar isn't showing up in the simulator. Screenshot

Should I be using a regular toolbar like the temporary one I have on the bottom? I'd prefer the search button for loading new addresses, and settings for the obvious, but then I want buttons that serve as navigations for moving from tab to tab. Should I simply implement a search bar above the map view and a settings button on the right? I'm new to xcode and it's kicking my ass.

EDIT: After changing the hidden to "self.navigationController?.setToolbarHidden(false, animated: true)" the toolbar appeared but at the bottom below the current toolbar with zoom and type buttons. So it looks as if it thinks it's a toolbar and only wants to put it at the bottom?


回答1:


self.navigationController.navigationBar.hidden = false;

Use above code to show navigation bar.




回答2:


I Believe you might be aligning the top of the Map View to the top of the top layout guide, if this is the case your toobar might be hidden behind the map view. I would change that constraint that constraint in the map view and use "vertical spacing" to the tool bar in the top and give it a value of 0.




回答3:


Don't add navigation bar manually If you are adding. You will get Your navigation bar with your navigation controller. In your viewWillAppear() put the line of code self.navigationController?.setNavigationBarHidden(false, animated: true).




回答4:


Swift 4 solution

Add this code to your ViewController:

   override func viewWillAppear(_ animated: Bool) {
        self.navigationController?.navigationBar.isHidden = false
    }


来源:https://stackoverflow.com/questions/36563012/my-navigation-bar-is-showing-up-in-storyboard-but-not-in-the-simulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!