UITapGestureRecognizer timeout? [英] UITapGestureRecognizer timeout?
问题描述
如果我在UITapGestureRecognizer上设置numberOfTapsRequired为2,那么用户在第一次点击再次点按触发识别器之后有一定的时间。有没有人知道如何找出准确的时间允许?
If I set numberOfTapsRequired to 2 on a UITapGestureRecognizer, then the user has a certain amount of time after his first tap to tap again to trigger my recognizer. Does anyone know how to find out the exact amount of time allowed?
通过类推,在Cocoa,NSEvent有doubleClickInterval类方法。我在iOS中寻找一个等效的UITapGestureRecognizer
By analogy, in Cocoa, NSEvent has the doubleClickInterval class method. I'm looking for an equivalent in iOS for UITapGestureRecognizer
推荐答案
答案是:0.35秒,至少今天iOS 5.1。
And the answer is: 0.35 seconds, at least as of today on iOS 5.1.
我创建了一个测试应用程序,它使用一对水龙头识别器来识别单和双水龙头来更新一对UIlabel。然后,我使用乐器UI自动化重复发送双击在抽头之间逐渐有更多的时间。在0.34秒时,一系列点击被识别为双击,但在0.35秒时,它们被识别为单个点击。
I created a test application that used a pair of tap recognizers to recognize both single and double taps to update a pair of UIlabels. I then used Instruments UI automation to repeatedly send double taps with progressively more time between the taps. At 0.34 seconds, a series of taps is recognized as a double tap, but at 0.35 seconds, they're recognized as single taps.
这非常像Lou的建议,但不同的是,我需要使用仪器。我可能没有办法模拟UIKit内的用户敲击。
This is very much like Lou's suggestion, but different in that I needed to use Instruments. I could find no way to simulate a user tap within UIKit.
这篇关于UITapGestureRecognizer timeout?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!