如果想要禁用单个页面侧滑,可以使用
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
但是如果关闭侧滑的代码写在viewWillAppear时,从其他页面侧滑返回到当前页面时,会卡死。
正确的代码:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//禁用右滑返回
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
//恢复右滑返回
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}