对于一个数据分析项目,我想在一个简单应用程序的日志文件中跟踪触摸力,大小和持续时间的测量值(我使用Apple文档网站上的Foodtracker app)。
我知道我可以从UITouch获得force,size和duration。但是
答案 0 :(得分:0)
您必须在视图控制器中覆盖触摸处理程序。
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
let touch = touches.first!
print("\(touch.force)")
print("\(touch.majorRadius)")
print("\(touch.timestamp)")
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesMoved(touches, with: event)
let touch = touches.first!
print("\(touch.force)")
print("\(touch.majorRadius)")
print("\(touch.timestamp)")
}
override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesCancelled(touches, with: event)
let touch = touches.first!
print("\(touch.force)")
print("\(touch.majorRadius)")
print("\(touch.timestamp)")
}