touchesBegan-只需要最后一次触摸操作-iPhone [英] touchesBegan - Only needs the last touch action - iPhone

查看:65
本文介绍了touchesBegan-只需要最后一次触摸操作-iPhone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

方法我正在做一些动作

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

我正在做其他动作.

如果我点击3次,touchesBegan将呼叫3次.我想要的是,如果用户连续轻按仅应执行的最后一次触摸操作.有没有可能?

If I'm tapping 3 times the touchesBegan will call 3 times. What I want is if the user continuously taps only the last touch action should perform. Is it possible or not?

推荐答案

您可以改用 UITapGestureRecognizer ,并在第一次点击后将其禁用.

You can try a UITapGestureRecognizer instead, and disable it after the first tap.

否则,您可以在 touchesEnded:withEvent: cancelPreviousPerformRequestsWithTarget:selector:object:中短暂使用 performSelector:withObject:afterDelay:>在 touchesBegan:withEvent:中.

Otherwise, you can use performSelector:withObject:afterDelay: with a short delay in touchesEnded:withEvent: and cancelPreviousPerformRequestsWithTarget:selector:object: in touchesBegan:withEvent:.

这有意义吗?

这篇关于touchesBegan-只需要最后一次触摸操作-iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆