Processing of touch events of UIResponder and UIView, uiresponderuiview
1. UIResponderUIResponder provides the following internal methods to handle events:
Touch event
-(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event;
-(Void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event;
-(Void) touchesEnded :( NSSet *) touches withEvent :( UIEvent *) event;
-(Void) touchesCancelled :( NSSet *) touches withEvent :( UIEvent *) event;
Accelerator event
-(Void) motionBegan :( UIEventSubtype) motion withEvent :( UIEvent *) event;
-(Void) motionEnded :( UIEventSubtype) motion withEvent :( UIEvent *) event;
-(Void) motionCancelled :( UIEventSubtype) motion withEvent :( UIEvent *) event;
Remote Control event
-(Void) remoteControlReceivedWithEvent :( UIEvent *) event;
2. Processing of touch events in UIView is a subclass of UIResponder. You can implement the following four methods to process different touch events:
One or more fingers start to touch the view. The system automatically calls the following method of view.
-(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event
When one or more fingers move on the view, the system automatically calls the following method of the view (this method will be continuously called as the fingers move)
-(Void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event
If one or more fingers exit the view, the system automatically calls the following method of the view.
-(Void) touchesEnded :( NSSet *) touches withEvent :( UIEvent *) event
Before the touch ends, a system event (such as incoming call) will interrupt the touch process, and the system will automatically call the following method of view.
(Void) touchesCancelled :( NSSet *) touches withEvent :( UIEvent *) event
Note: touches stores all UITouch objects.