Search code examples
iosswiftmmdrawercontroller

MMDrawerController doesn't close if setNavigationBarHidden is true


I'm using MMDrawerController, which works fine everywhere except on the two views where I have self.navigationController?.navigationBarHidden = true. On these views I can open the slider, but I cannot close it, the button doesn't respond anymore. Here is my code in the slider:

let viewController = self.storyboard?.instantiateViewControllerWithIdentifier("ProfileViewController") as! ProfileViewController
viewController.currentUser = APP_DELEGATE.loggedInUser

let navigationController = self.mm_drawerController.centerViewController as! UINavigationController

navigationController.viewControllers = [viewController]

self.mm_drawerController.toggleDrawerSide(MMDrawerSide.Left, animated: true, completion: nil)

and the one on profile page where the navigation bar is hidden:

@IBAction func menuTapped(sender: AnyObject) {

    println("Profile: menu tapped")
    if let drawer = self.mm_drawerController
    {
        drawer.toggleDrawerSide(MMDrawerSide.Left, animated: true, completion: nil)

    }

}

Any idea why it doesn't work?


Solution

  • In the end I fixed it by adding in appDelegate didFinishLaunchingWithOptions:

    let drawer = application.windows.first?.rootViewController as! MMDrawerController
    drawer.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView | MMCloseDrawerGestureMode.TapCenterView