touchesBegan - 只需要最后的触摸动作 - iPhone

时间:2013-01-08 10:51:05

标签: iphone ios touch

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

方法我正在做一些动作并且在

- (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

方法我正在做其他一些行动。

如果我点击3次触摸,则会打3次。我想要的是如果用户连续点击只应执行的最后一次触摸操作。有可能吗?

1 个答案:

答案 0 :(得分:1)

您可以尝试使用UITapGestureRecognizer,然后在第一次点击后将其停用。

否则,您可以performSelector:withObject:afterDelay:中的touchesEnded:withEvent:使用cancelPreviousPerformRequestsWithTarget:selector:object:touchesBegan:withEvent:中的{{1}}短暂延迟。

这有意义吗?

相关问题