Question

I have a problem about gesture recognizer. I have two gesture recognizers in my view, one added to the background superview to swipe to change background color, the other one is added to a subview which could be dragged around.

The problem is the drag gesture is interfered with the swipe. When I drag the view around, in some case, drag operation will be recognized as a swipe and trigger the swipe operation. I don't want this, I just want swipe could be recognized after finish this drag operation. This situation is more often when I drag the subview around quickly. Every time during the drag, the swipe operation will be triggered.

Was it helpful?

Solution

You need to setup your lesser UIGestureRecognizer with requireGestureRecognizerToFail: and pass your recognizer that you want to be important to it.

UIView *subview = ....
[self addSubview:subview];

[self.gestureRecognizer requireGestureRecognizerToFail:subview.gestureRecognizer];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top