禁用滑动返回手势需要在改界面的ViewController中添加如下代码
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// 禁用返回手势
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
}
如果只是该界面禁用滑动返回手势,还需要添加如下代码使其他界面能够继续使用滑动返回手势:
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
// 开启返回手势
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
如果以上都不可以的话 可以采用 一下方法
方法一
id traget = self.navigationController.interactivePopGestureRecognizer.delegate;
UIPanGe