I need to detect two fingers with function touchesMoved. The code will print out the number of toches. The program works well with normal UIView (prints touches.count=2) but not with ARView (always prints touches.count=1).
Any solution?
import UIKit
import RealityKit
class GameViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
view.isMultipleTouchEnabled = true
// // This code works for detecting two fingers
// let v = UIView(frame: view.frame)
// v.backgroundColor = .green
// view.addSubview(v)
// v.isMultipleTouchEnabled = true
// This code doesn't work for detecting two fingers
let arView = ARView(frame: view.frame,
cameraMode: .nonAR,
automaticallyConfigureSession: true)
view.addSubview(arView)
arView.isMultipleTouchEnabled = true
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touchesBegan, touches.count=\(touches.count)")
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
print("touchesMoved, touches.count=\(touches.count)")
}
}
The following code works with any UIKit's view, including arView.
Results: