質問

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.

役に立ちましたか?

解決

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];
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top