我想实现二次单击iPad以显示选项。
let tapTwoRecog = UITapGestureRecognizer(target: self, action: #selector(tapTwoAsLongPress(gesture:)))
tapTwoRecog.numberOfTouchesRequired = 2
tapTwoRecog.numberOfTapsRequired = 1
tapTwoRecog.allowedTouchTypes = [NSNumber(value: UITouch.TouchType.direct.rawValue), NSNumber(value: UITouch.TouchType.indirect.rawValue)]
tableView.addGestureRecognizer(tapTwoRecog)
tableView.isMultipleTouchEnabled = true但它只能由屏幕上的触摸触发。使用触控板不会触发任何东西。我已经将UIApplicationSupportsIndirectInputEvents设置为YES/NO。
发布于 2021-08-03 12:04:54
我刚刚在这个网站上找到了答案:https://pspdfkit.com/blog/2020/level-up-your-trackpad-support-using-uiinteraction/
if #available(iOS 13.4, *) {
let tapTwoRecog = UITapGestureRecognizer(target: self, action: #selector(tapTwoAsLongPress(gesture:)))
tapTwoRecog.allowedTouchTypes = [NSNumber(value: UITouch.TouchType.indirectPointer.rawValue)]
tapTwoRecog.buttonMaskRequired = .secondary
tableView.addGestureRecognizer(tapTwoRecog)
}UIApplicationSupportsIndirectInputEvents必须为YES。
https://stackoverflow.com/questions/68635030
复制相似问题