MMDrawerController 手势与系统导航返回手势冲突

尤飞尘
2023-12-01
  • push后发现左滑返回偶尔返回到主界面,偶尔又返回到左侧菜单页,当所有的controller都继承自基类处理方法在 viewWillAppear和dissAppear中进行打开和关闭操作(判断类型).
if ([self isKindOfClass:NSClassFromString(@"xxx")] ) {
    //判断需要打开滑动菜单手势的类
    [self openMMDrawCtroller];
 }else{        
     //不需要的关闭
    [self closeMMDrawCtroller];
}
  • 如果不是继承基类,需要再该controller中
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //返回手势
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self closeMMDrawCtroller];
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    return YES ;
}

- (void)closeMMDrawCtroller{
    //设置抽屉菜单的显示隐藏手势
    [appDelegate.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeNone];
    [appDelegate.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeNone];
}

- (void)openMMDrawCtroller{
    [appDelegate.drawerController setOpenDrawerGestureModeMask:MMOpenDrawerGestureModeAll];
    [appDelegate.drawerController setCloseDrawerGestureModeMask:MMCloseDrawerGestureModeAll];
}
 类似资料: