所以我实现了一个单指长按手势识别器,但识别器似乎总是缺少 UIGestureRecognizerStateBegan 状态...如果我长按不移动手指并抬起,我会收到 StateEnded 调试消息。如果我长按并稍微移动手指然后抬起,我会收到 StateChanged 和 StateEnded 调试消息。但我从未见过 StateBegan。
UIPanGestureRecognizer 没有这个问题 - Pan 从 Began->Changed->Ended 获取所有正确的手势状态。
- (void)handleLongPress:(UILongPressGestureRecognizer *)recognizer {
CGPoint location = [recognizer locationInView:self];
switch (recognizer.state) {
case UIGestureRecognizerStateBegan:
NSLog(@"!!!!handleLongPress: StateBegan !!!!!");
break;
case UIGestureRecognizerStateChanged:
NSLog(@"!!!!handleLongPress: StateChanged !!!!!");
break;
case UIGestureRecognizerStateEnded:
NSLog(@"!!!!handleLongPress: StateEnded !!!!!");
break;
default:
break;
}
}