簡體   English   中英

UILongPressGestureRecognizer 接受靈活的觸摸量

[英]UILongPressGestureRecognizer to accept a flexible amount of touches

我有一個 UILongPressGestureRecognizer ,當屏幕上有 1 根手指時會觸發它。 但是,只要我放 2 根手指,function 就不再觸發,我需要為 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 並自己分析了手勢

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM