iOS 禁用系统侧滑返回

2020-07-20  本文已影响0人  狂暴的小蜗牛

1.在viewDidAppear:中禁用手势

// 禁用侧滑返回手势

if([self.navigationControllerrespondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    //这里对添加到右滑视图上的所有手势禁用
    for (UIGestureRecognizer *popGesture in self.navigationController.interactivePopGestureRecognizer.view.gestureRecognizers) {
        popGesture.enabled=NO;
    }
}

2.viewWillDisappear:中开启手势

if([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)])
{
    //这里对添加到右滑视图上的所有手势禁用
    for (UIGestureRecognizer *popGesture in self.navigationController.interactivePopGestureRecognizer.view.gestureRecognizers) {
        popGesture.enabled=YES;
    }
}
上一篇 下一篇

猜你喜欢

热点阅读