我有关于手势识别器的问题。 我在视图中有两个手势识别器,一个添加到背景超级视图中以滑动以更改背景颜色,另一个添加到可拖动的子视图中。
问题是拖动手势受到滑动的干扰。 当我拖动视图时,在某些情况下,拖动操作将被识别为滑动并触发滑动操作。 我不想要这个,我只想在完成这个拖动操作后才能识别滑动。 当我快速拖动子视图时,更常见这种情况。 每次拖动过程中,都会触发滑动操作。
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.
最满意答案
您需要使用requireGestureRecognizerToFail:设置较小的UIGestureRecognizer requireGestureRecognizerToFail:并传递您想要对其重要的识别器。
UIView *subview = .... [self addSubview:subview]; [self.gestureRecognizer requireGestureRecognizerToFail:subview.gestureRecognizer];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];更多推荐
发布评论