我正在制作键盘扩展,所以我希望在双击 shift 时激活大写锁定,并让它在单击时定期移动。我的代码:
var selector: Selector = "lockCapsLock"
var singleTapSelector: Selector = "shift"
let doubleTapRecognizer = UITapGestureRecognizer(target: self, action: selector)
let singleTapRecognizer = UITapGestureRecognizer(target: self, action: singleTapSelector)
singleTapRecognizer.numberOfTapsRequired = 1
doubleTapRecognizer.numberOfTapsRequired = 2
v.addGestureRecognizer(doubleTapRecognizer)
v.addGestureRecognizer(singleTapRecognizer)
singleTapRecognizer.requireGestureRecognizerToFail(doubleTapRecognizer)
我遇到的问题是,当我单击时它需要太长时间才能使双击失败,因此按下 shift 会有延迟。如果我太快按 shift 然后按另一个键,它会变成小写,但是下一个键会正确移动。双击工作正常。
如何减少单击的延迟?