Мне нужно отслеживать каждое прикосновение на айфоне, и вроде бы все получилось, но определяется касание только вне кнопок или текстов. ТО есть если жмакать по пустой области то все работает, а если по кнопке, то касание уже не записывается. Кто нибудь может подсказать, как это исправить?
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
super.touchesBegan(touches, with: event)
swiped = false
if let touch = touches.first{
force = touch.force/touch.maximumPossibleForce
lastPoint = touch.location(in: view)
let time = Date().timeIntervalSinceReferenceDate
print(force,lastPoint,time)
}
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent!) {
super.touchesMoved(touches, with: event)
swiped = true
if let touch = touches.first {
let currentPoint = touch.location(in: view)
if #available(iOS 9.0, *) {
if traitCollection.forceTouchCapability == UIForceTouchCapability.available {
// 3D Touch capable
force = touch.force/touch.maximumPossibleForce
lastPoint = currentPoint
let time = Date().timeIntervalSinceReferenceDate
print(force,lastPoint,time)
self.logToFile(data: "X,Y-\(lastPoint), Forse-\(force) , Time-\(time) \n".description.data(using: String.Encoding.utf8)!)
}
}
}
}