Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conflict between pan and swipe gesture in the same view?

Is there anyway to distinguish pan and swipe gesture in the same view? I have 2 gestures work on a same view simultaneously by using the delegate

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

I did set the pan gesture's property minimumNumberOfTouches = 1. The problem is when I'm panning, the swipe gesture is triggered. How to make swipe gesture stop when I'm in panning process?

like image 687
Quang L. Avatar asked Nov 21 '25 15:11

Quang L.


1 Answers

Try to call the requireGestureRecognizerToFail: method in your swipe gesture

[swipeGestureRecognizer requireGestureRecognizerToFail:panGestureRecognizer];

This should cause the pan gesture to cancel the swipe gesture if the pan gesture is recognized or began.

like image 79
Valent Richie Avatar answered Nov 24 '25 23:11

Valent Richie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!