-->

SlideOutMenu remove Navigation Bar

2019-09-14 06:24发布

问题:

I use SWRevealViewController for my project. Currently, the problem is that when the project starts, Navigation bar show with title of "MyApp". But, navigation bar disappears when I click on Home

If I add a Navigation Bar in view controller, there will be 2 navigation bars at first run. One navigation will automatically disappear when I click on Home link.

How to do to get the first image appearance when I click on Home link? I'm using Swift 3.

回答1:

You could try set the navigation bar to not hidden in the viewWillAppear.

override func viewWillAppear(_ animated: Bool) {

    super.viewWillAppear(animated)

    navigationController?.setNavigationBarHidden(false, animated: false)

    // ...
}

However I presume the reason the navigation bar is hidden is because the controller is being presented modally and not being pushed onto the main navigation controller. If this is the case, then you will need to probably do something with the SWRevealViewController and push the controller onto the main navigation controller.

Check out the Basic API usage for SWRevealViewController here and here is an alternative that has codeless storyboard implementation and is very easy to configure.



回答2:

(Posted on behalf of the OP).

I'm not sure the way I solved is right or wrong. But, it works for me. I remove default Navigation Bar by disabling the bar visibility. Then, I add new Navigation Bar in Home page. After I run the app, my new Navigation Bar appears when I press on the Home button.