要屏蔽/开启某一个UIViewController的系统自带的右滑手势实现返回的功能。如下步骤:

(1)在.m文件中实现如下代码:(一般写在viewDidLoad方法中)

- (void)viewDidLoad {
    [super viewDidLoad];
    if ([[UIDevice currentDevice].systemVersion floatValue]>=7.0) {
        if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
            self.navigationController.interactivePopGestureRecognizer.enabled = YES;
            self.navigationController.interactivePopGestureRecognizer.delegate = self;
        }  
    }  

}

(2)在此viewController的头文件中加入代理<UIGestureRecognizerDelegate>;

@interface BaseViewController ()<UIGestureRecognizerDelegate>

@end
(2)实现代理方法

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
    if ([self.navigationController.viewControllers count] == 1) {
        return NO;
    }else{
        return YES;
    }
}



相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-01
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案