如果 setNavigationBarHidden 为真,MMDrawerController 不会关闭
MMDrawerController doesn't close if setNavigationBarHidden is true
我正在使用 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)
}
}
知道为什么它不起作用吗?
最后我通过添加 appDelegate didFinishLaunchingWithOptions
:
修复了它
let drawer = application.windows.first?.rootViewController as! MMDrawerController
drawer.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView | MMCloseDrawerGestureMode.TapCenterView
我正在使用 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)
}
}
知道为什么它不起作用吗?
最后我通过添加 appDelegate didFinishLaunchingWithOptions
:
let drawer = application.windows.first?.rootViewController as! MMDrawerController
drawer.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView | MMCloseDrawerGestureMode.TapCenterView