我已经设置了一个UISwipeGestureRecognizer
:
UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc] initWithTarget:delegate action:@selector(handleSwipeGesture:)];
swipe.direction = UISwipeGestureRecognizerDirectionUp;
[self addGestureRecognizer:swipe];
[swipe release];
滑动手势会使玩家向滑动方向移动。但是我需要让玩家一直保持移动状态,直到触发滑动手势的手指离开屏幕。我尝试使用touchesEnded:方法,但它要求首先进行非滑动操作。如何获取触发滑动手势的触摸事件?如何检测当手指离开屏幕时的状态?
if (gesture.state == UIGestureRecognizerState.Ended)
或者简写为if (gesture.state == .Ended)
。 - Troy