Using a subclassed UIView
and overriding touchesBegan:
, touchesMoved:
and touchesEnded:
. Done this many times with success, but now that I'm working with 3D Touch enabled devices, my movements are being cancelled by the movement they should receive.
touchesMoved:
will receive force changes correctly, but if there is force + location change, I receive a cancelled event.
Logging from a tap
Touches moved, force : 0.62, point : {154.5, 175}
Touches moved, force : 1.40, point : {154.5, 175}
Touches moved, force : 1.98, point : {154.5, 175}
Touches moved, force : 2.13, point : {154.5, 175}
Touches ended
Touches moved, force : 0.58, point : {191, 203}
Touches moved, force : 1.15, point : {191, 203}
Touches moved, force : 1.42, point : {191, 203}
Touches ended
Logging from a move
Touches moved, force : 1.57, point : {170, 231}
Touches moved, force : 1.68, point : {170, 231}
Touches moved, force : 1.88, point : {170, 231}
Touches moved, force : 2.12, point : {170, 231}
Touches moved, force : 2.33, point : {170, 231}
Touches moved, force : 2.58, point : {170, 231}
Touches moved, force : 2.85, point : {170.5, 233}
Touches moved, force : 3.23, point : {170.5, 233.5}
Touches moved, force : 3.70, point : {170.5, 234}
Touches moved, force : 4.25, point : {170.5, 234.5}
Touches moved, force : 4.78, point : {170.5, 235}
Touches moved, force : 5.28, point : {170.5, 236}
Touches moved, force : 5.70, point : {170.5, 237}
Touches moved, force : 6.00, point : {171, 239}
Touches cancelled.
Touches moved, force : 0.02, point : {142, 228}
Touches moved, force : 0.08, point : {142, 228}
Touches moved, force : 0.15, point : {142, 228}
...
Touches moved, force : 0.57, point : {142, 228}
Touches moved, force : 0.58, point : {142, 228}
Touches moved, force : 0.63, point : {142, 228}
Touches moved, force : 0.72, point : {142, 228}
Touches moved, force : 0.78, point : {142, 228}
Touches moved, force : 0.85, point : {144, 230.5}
Touches moved, force : 0.93, point : {144.5, 231}
Touches moved, force : 1.02, point : {145, 232}
Touches moved, force : 1.15, point : {146.5, 232.5}
Touches moved, force : 1.33, point : {147.5, 233.5}
Touches moved, force : 1.55, point : {148.5, 234.5}
Touches moved, force : 1.82, point : {150, 236.5}
Touches cancelled.
Just discovered that a gesture recognizer will, by default, cancel other touches in its view. Set
gesture.cancelsTouchesInView = NO
and all is resolved.