在两种不同的情况下,我必须检测蓝牙键盘上的外部触摸:
我使用了UIKeyCommand类,并且在第一种情况下都可以正常工作,但是长按我不知道该怎么做。
反正有这样做吗? 还是有一种方法可以将UILongPressGestureRecognizer添加到UIKeyCommand?
这是实际的代码:
override var canBecomeFirstResponder: Bool {
return true
}
override var keyCommands: [UIKeyCommand]? {
return [
UIKeyCommand(input: UIKeyCommand.inputDownArrow, modifierFlags: [], action: #selector((DownArrowPress))),
UIKeyCommand(input: UIKeyCommand.inputUpArrow, modifierFlags: [], action: #selector((UpArrowPress))),
UIKeyCommand(input: " ", modifierFlags: [], action: #selector((SpaceKeyPress)))]
}
@objc func DownArrowPress(_ sender: UIKeyCommand) {
//...
}
@objc func UpArrowPress(_ sender: UIKeyCommand) {
//...
}
@objc func SpaceKeyPress(_ sender: UIKeyCommand) {
switch("touch or long touch"){
case "touch":
//...
case "long touch":
//HOW CAN I DETECT THIS ONE?
default:
//...
}
}