在UISwipeGesture后检测手指何时抬起[Recognizer] [英] Detect when the finger lifts after a UISwipeGesture[Recognizer]
问题描述
我已经设置了 UISwipeGestureRecognizer
:
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:delegate action:@selector(handleSwipeGesture:)];
swipe.direction = UISwipeGestureRecognizerDirectionUp;
[self addGestureRecognizer:swipe];
[swipe release];
滑动使玩家朝滑动方向移动.但是,我需要播放器继续移动,直到将进行滑动的手指从屏幕上抬起为止.我尝试使用touchesEnded:方法,但它要求首先进行非滑动触摸.如何获得做出滑动手势的触摸?如何检测何时将触摸从屏幕上移开?
A swipe makes the player move in the direction of the swipe. I need the player to keep moving, though, until the finger that made the swipe is lifted off the screen. I've tried using the touchesEnded: method but it requires that a non-swiping touch be made first. How can I get the touch that made the swipe gesture? How can I detect when that touch is lifted off the screen?
推荐答案
在查看了苹果的文档之后,我发现了UIGestureRecognizer的以下属性:
After looking through Apple's documentation, I found this property of UIGestureRecognizer:
@property(nonatomic) BOOL cancelsTouchesInView
将其设置为 NO
可使接收者的视图处理手势识别器接收的属于多点触摸序列的所有触摸.
Setting it to NO
lets the receiver's view handle all touches that are part of the multi-touch sequence the gesture recognizer receives.
这篇关于在UISwipeGesture后检测手指何时抬起[Recognizer]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!