我正在处理Touches
代表和UITapGestureRecognizer
单击。以下是方法。当我单击我的视图时,我得到三个事件,顺序为TouchesBegan
、SingleTap
和TouchesEnded
。TouchesEnded
当我检测到时,是否有停止事件SingleTap
?基本上我不想在没有发生的情况下执行TouchesEnded
任务TouchesMoved
。我已经使用 failTouchEnded BOOL 变量完成了这项工作,SingleTap
并在 TouchesEnded 中对其进行了检查,但不确定这是否是个好主意!
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
failTouchEnded = NO;
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if(failTouchEnded) return;
}
- (void)GestureView:(GestureView*)view handleSignleTap:(UITapGestureRecognizer*)recognizer {
failTouchEnded = YES;
}