My navigation bar is showing up in storyboard but

2019-07-30 07:38发布

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?

4条回答
我想做一个坏孩纸
2楼-- · 2019-07-30 07:50

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).

查看更多
萌系小妹纸
3楼-- · 2019-07-30 08:02

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.

查看更多
我命由我不由天
4楼-- · 2019-07-30 08:06

Swift 4 solution

Add this code to your ViewController:

   override func viewWillAppear(_ animated: Bool) {
        self.navigationController?.navigationBar.isHidden = false
    }
查看更多
贪生不怕死
5楼-- · 2019-07-30 08:13
self.navigationController.navigationBar.hidden = false;

Use above code to show navigation bar.

查看更多
登录 后发表回答