Search code examples
iosswiftmmdrawercontroller

swift hiding navbar in mmdrawercontroller


I have created a slidout menu for kmy app with mmdrawercontroller from github.

It all works perfectly but i can't get rid of the nav bar at the top. it is overlapping part of my many but also shows up on all other pages. I need it gone. i have found the following code

navigationController?.setNavigationBarHidden(navigationController?.navigationBarHidden == false, animated: true)

But i have no idea where to place it. I tried it in appdelegate, in the leftsliderviewcontroller, in the button who invokes the mmdrawercontroller. But nothing seems to work.

Also in code that comes with the mmdrawercontroller i can't find anywhere a bool for this setting.

Can any one show me how to hide this navigationbar.

thanks.


Solution

  • If you want to hide your UINavigationBar in some UIViewControllers the you need to call self.navigationController?.navigationBarHidden = true in your viewWillAppear like in the following way:

    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        self.navigationController?.navigationBarHidden = true
    }
    

    And the above code hide your UINavigationBar. I hope this help you.