简体   繁体   English

UILongPressGestureRecognizer 接受灵活的触摸量

[英]UILongPressGestureRecognizer to accept a flexible amount of touches

I have a UILongPressGestureRecognizer which is fired when there is 1 finger on the screen.我有一个 UILongPressGestureRecognizer ,当屏幕上有 1 根手指时会触发它。 However, as soon as I put 2 fingers, the function is not fired anymore and I need to create a new gesture for 2 fingers.但是,只要我放 2 根手指,function 就不再触发,我需要为 2 根手指创建一个新手势。 How to have UILongPressGestureRecognizer to accept a flexible amount of touches?如何让 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
}

I ended up using TouchesBegan / Moved / Ended and analyzed gestures by myself我最终使用了 TouchesBegan / Moved / Ended 并自己分析了手势

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM