1. 程式人生 > >iOS 8 完美禁止右滑返回

iOS 8 完美禁止右滑返回

先引入代理協議

- (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;

}