我正试图快速检测出印刷机,我无法检测出印刷机。这是我的代码:
override func pressesBegan(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("test1")
}
override func pressesChanged(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("test2")
}
override func pressesEnded(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("test3")
}
override func pressesCancelled(_ presses: Set<UIPress>, with event: UIPressesEvent?) {
print("test4")
}
在物理苹果电视和模拟器上执行代码后,控制台仍为空。为什么没有检测到印刷机?任何帮助将不胜感激。
答案 0 :(得分:0)
我找到了答案,但我不确定为什么覆盖方法不起作用。
let press:UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(pressed))
press.allowedPressTypes = [NSNumber(value: UIPressType.select.rawValue)]
view.addGestureRecognizer(press)