I ran into an issue when shaking the device. It was due to unsafe unwrapping of the touches in the for statement:
override public func sendEvent(_ event: UIEvent) {
let touches = event.allTouches
for touch in touches! {
...
I got around it by changing the code as shown below:
override public func sendEvent(_ event: UIEvent) {
if let touches = event.allTouches {
for touch in touches {
switch touch.phase {
case .began:
self.controller.touchBegan(touch, view: self)
case .moved:
self.controller.touchMoved(touch, view: self)
case .ended, .cancelled:
self.controller.touchEnded(touch, view: self)
default:
break
}
}
}
super.sendEvent(event)
}
First, thanks for a very useful code.
I ran into an issue when shaking the device. It was due to unsafe unwrapping of the touches in the for statement: override public func sendEvent(_ event: UIEvent) { let touches = event.allTouches for touch in touches! { ...
I got around it by changing the code as shown below: