Search code examples
iosuipangesturerecognizer

UIScreenEdgePanGestureRecognizer inconsistency issue


I have a UIScreenEdgePanGestureRecognizer (as part of a custom pop gesture) that works 85-90% of the time. There's that 10-15% when it just doesn't fire no matter how perfectly you swipe. The UIScreenEdgePanGestureRecognizer is competing with a UIScrollView that contains the navigation controller which also detects gestures in the same direction (horizontal) so I suspect that may be the issue.

Is this relatively common to have a UIScreenEdgePanGestureRecognizer fire inconsistently, particularly when UIKit has to take its best guess if the gesture is a screen-edge pop or a regular pan? And is there a way to reconfigure UIScreenEdgePanGestureRecognizer to get it working with a higher success rate, perhaps by enlarging the rectangle?


Solution

  • Prevent UIScrollView's UIPanGestureRecognizer from blocking UIScreenEdgePanGestureRecognizer:

    [scrollView.panGestureRecognizer requireGestureRecognizerToFail:self.navigationController.interactivePopGestureRecognizer];
    

    This method creates a relationship with another gesture recognizer that delays the receiver’s transition out of UIGestureRecognizerStatePossible.