我试图了解UIEvent
,UITouch
对象的重用,所以我尝试测试,但结果使我感到困惑
这是我的代码
class CustomView: UIView {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("==========================")
print("Event Object : \(Unmanaged.passUnretained(event!).toOpaque())")
for (index, touch) in touches.enumerated() {
print("\(index)'s, UITouch Object : \(Unmanaged.passUnretained(touch).toOpaque())")
}
print("==========================")
}
}
class ViewController: UIViewController {
@IBOutlet weak var skyBlueView: CustomView!
var previousTouch:UITouch?
var currentTouch:UITouch?
override func viewDidLoad() {
super.viewDidLoad()
self.view.isMultipleTouchEnabled = true
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
print("==========================")
print("Event Object : \(Unmanaged.passUnretained(event!).toOpaque())")
for (index, touch) in touches.enumerated() {
print("\(index)'s, UITouch Object : \(Unmanaged.passUnretained(touch).toOpaque()) Tap Count: \(touch.tapCount)")
}
print("==========================")
}
}
我希望相同坐标的触摸对象相同
这是我的问题
何时释放UIEvent对象? UIEvent仍被重用
在同一坐标上,拍子计数增加,但是对象不同 如何在UITouch对象之间共享点击计数