UILongPressGestureRecognizer 接受灵活数量的触摸
UILongPressGestureRecognizer to accept a flexible amount of touches
我有一个 UILongPressGestureRecognizer,它会在屏幕上有一根手指时触发。但是,一旦我放了 2 个手指,该功能就不再被触发,我需要为 2 个手指创建一个新的手势。
如何让 UILongPressGestureRecognizer 接受灵活数量的触摸?
let longScreenGesture = UILongPressGestureRecognizer(target: self, action: #selector(screenTapped(_:)))
longScreenGesture.minimumPressDuration=0.1
longScreenGesture.allowableMovement=0
longScreenGesture.numberOfTouchesRequired=1
sceneView.isMultipleTouchEnabled=true
sceneView.addGestureRecognizer(longScreenGesture)
@objc func screenTapped(_ sender: UILongPressGestureRecognizer)
{
print(sender.numberOfTouches) // -> Always displays 1
}
我最终使用了 TouchesBegan / Moved / Ended 并自己分析了手势
我有一个 UILongPressGestureRecognizer,它会在屏幕上有一根手指时触发。但是,一旦我放了 2 个手指,该功能就不再被触发,我需要为 2 个手指创建一个新的手势。 如何让 UILongPressGestureRecognizer 接受灵活数量的触摸?
let longScreenGesture = UILongPressGestureRecognizer(target: self, action: #selector(screenTapped(_:)))
longScreenGesture.minimumPressDuration=0.1
longScreenGesture.allowableMovement=0
longScreenGesture.numberOfTouchesRequired=1
sceneView.isMultipleTouchEnabled=true
sceneView.addGestureRecognizer(longScreenGesture)
@objc func screenTapped(_ sender: UILongPressGestureRecognizer)
{
print(sender.numberOfTouches) // -> Always displays 1
}
我最终使用了 TouchesBegan / Moved / Ended 并自己分析了手势