如果setNavigationBarHidden为true,则MMDrawerController不会关闭

时间:2015-07-16 12:16:11

标签: ios swift mmdrawercontroller

我正在使用MMDrawerController,除了我有self.navigationController?.navigationBarHidden = true的两个视图外,它在任何地方都可以正常工作。在这些视图中,我可以打开滑块,但我无法关闭它,按钮不再响应。这是滑块中的代码:

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)

以及隐藏导航栏的个人资料页面上的那个:

@IBAction func menuTapped(sender: AnyObject) {

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

    }

}

知道它为什么不起作用?

1 个答案:

答案 0 :(得分:2)

最后,我通过添加appDelegate didFinishLaunchingWithOptions来修复它:

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