Where can I get a touch event with the UITouchPhaseStationary phase?

In these methods, I get the corresponding phases:
touchBegan: withEvent: UITouchPhaseBegan,
touchesMoved: withEvent: UITouchPhaseMoved,
touchesEnded: withEvent: UITouchPhaseEnded,
touchsCancelled: withEvent: UITouchPhaseCancelled.

Where can I get a touch event with this phase: UITouchPhaseStationary?

+4
source share
2 answers

You can accept a touch in the interval between events <<20> as motionless.

( UITouchPhaseStationary exists because of multi-touch. If one finger moves and the other doesn't, the Moved event still fires, but a stationary touch will be in the UITouchPhaseStationary phase.)

+2
source

Yes, you can. but iOS does not send touch events with a fixed finger. As @KennyTM said, they actually go into the allTouches array of the allTouches whenever any of the 4 types of touches happen.

 const char* touchPhaseName[] = { "UITouchPhaseBegan", // whenever a finger touches the surface. "UITouchPhaseMoved", // whenever a finger moves on the surface. "UITouchPhaseStationary", // whenever a finger is touching the surface but hasn't moved since the previous event. "UITouchPhaseEnded", // whenever a finger leaves the surface. "UITouchPhaseCancelled" } ; - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { for( UITouch* touch in event.allTouches ) { // event.allTouches INCLUDES the other fingers, some of which may still be stationary printf( "Touch id=%d is in phase %s\n", touch, touchPhaseName[touch.phase] ) ; } } 
0
source

Source: https://habr.com/ru/post/1299624/


All Articles