self.navigationController.interactivePopGestureRecognizer.enabled = NO;不适用于iOS 8

前端之家收集整理的这篇文章主要介绍了self.navigationController.interactivePopGestureRecognizer.enabled = NO;不适用于iOS 8前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我想在滑动视图控制器时禁用弹出手势,但下面的行在iOS 8中不起作用:

self.navigationController.interactivePopGestureRecognizer.enabled = NO;

提前致谢

解决方法

在您希望禁用它的viewcontroller中,添加以下行:

- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.delegate = self;
    }
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    }

}

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

猜你在找的Xcode相关文章