我正在处理Touches
个代表和UITapGestureRecognizer
进行单击。以下是方法。当我点击我的视图时,我会按TouchesBegan
,SingleTap
和TouchesEnded
的顺序获得三个事件。当我检测到TouchesEnded
时,是否有停止SingleTap
事件? Basicaaly如果TouchesEnded
没有发生,我不想在TouchesMoved
执行任务。我使用SingleTap
中的failTouchEnded BOOL变量并在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;
}
答案 0 :(得分:0)
gestureRecognizer有一个属性cancelsTouchesInView。如果是(这是默认的),如果手势识别器识别出手势,则取消触摸。所以你会取消触摸而不是触摸结束。如果不是,则应将delayedTouchesEnded设置为YES