How to turn off the automatic gesture to go back a view with a navigation controller?

后端 未结 6 1052
清歌不尽
清歌不尽 2020-12-13 06:56

So I\'m noticing all of my views are receiving the gesture to go back (pop a view) when the user swipes on the very left side of the screen (in either orientation) (

6条回答
  •  醉酒成梦
    2020-12-13 07:46

    I use this solution in my project, it disables only interactivePopGestureRecognizer and allows you to use another gesture recognizers.

    - (void)viewDidLoad {
    
        [super viewDidLoad];
    
        if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
    
            self.navigationController.interactivePopGestureRecognizer.enabled = NO;
            self.navigationController.interactivePopGestureRecognizer.delegate = self;
    
        }
    
    }
    
    
    - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    
        if ([gestureRecognizer isEqual:self.navigationController.interactivePopGestureRecognizer]) {
    
            return NO;
    
        } else {
    
            return YES;
    
        }
    
    }
    

提交回复
热议问题