MMDrawerController无法关闭抽屉 [英] MMDrawerController can't close drawer

查看:119
本文介绍了MMDrawerController无法关闭抽屉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的应用程序中使用MMDrawerController,但是我无法通过中央视图上的手势关闭侧面抽屉.我在应用程序的其他地方使用MMDrawerController取得了巨大的成功,但无法弄清楚为什么在这种情况下它不起作用.

I'm trying to use MMDrawerController in my application, but I can't get the side drawer to close with gestures on the center view. I've used MMDrawerController somewhere else in my app with great success, but can't figure out why its not working in this case.

顶级视图控制器是UINavigationController,其默认视图控制器是MasterViewController(下面的源).此类扩展了MMDrawerController并为我想要的内容(中心和右边,关闭手势,最大宽度)配置了视图.中心视图有一个按钮可打开抽屉.抽屉打开后,我将无法用中心视图上的手势将其关闭.我在抽屉中添加了一个按钮,它可以通过编程方式关闭抽屉,但是我需要能够在中心视图中进行制表/平移.

The top-level View Controller is a UINavigationController, whose default view controller is the MasterViewController (source below). This class extends MMDrawerController and configures the view for what I want (center and right, close gestures, max width). The center view has a button that opens the drawer. Once the drawer is open I can't close it with gestures on the center view. I added a button to the drawer and it can close the drawer programmatically, but I need to be able to tab/pan on the center view.

MasterViewController类:MMDrawerController {

class MasterViewController: MMDrawerController {

override func viewDidLoad() {
    let centerView = storyboard!.instantiateViewControllerWithIdentifier("CenterControllerName") as? CenterControllerType
    super.setCenterViewController(centerView, withCloseAnimation: false, completion: nil)
    let drawer = storyboard!.instantiateViewControllerWithIdentifier("Drawer") as? DrawerType
    super.rightDrawerViewController = drawer
    super.setMaximumRightDrawerWidth(200, animated: true, completion: nil)
    super.closeDrawerGestureModeMask = MMCloseDrawerGestureMode.PanningCenterView | MMCloseDrawerGestureMode.TapCenterView
}

}

打开抽屉的功能:

@IBAction func drawerButtonPressed(sender: AnyObject) {
    drawer?.openDrawerSide(MMDrawerSide.Right, animated: true, completion: nil)
}

推荐答案

我可以通过以下方法解决此问题:将ContainerView放置为视图中的唯一对象,然后从ViewController配置MMDrawerContainer.这似乎不是正确的答案,但从用户的角度来看,所有内容和功能都正确无误.

I was able to work around this by placing a ContainerView as the only object in my view and then configuring the MMDrawerContainer from my ViewController. It doesn't seem like the right answer but everything looks and functions right from the user's perspective.

这篇关于MMDrawerController无法关闭抽屉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆