Touch events
Accelerometer Events
Remote control Events
Responder Object
Not all objects in iOS can handle events, only objects that inherit Uiresponder can receive and handle events. We call it "responder object."
UIApplication, Uiviewcontroller, and UIView inherit from Uiresponder, so they are both responder objects that can receive and handle events
Second, Uiresponder
Uiresponder internally provides the following methods to handle events
Touch events
-(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;
Accelerometer Events
-(void) Motionbegan: (uieventsubtype) Motion withevent: (uievent *) event;
-(void) motionended: (uieventsubtype) Motion withevent: (uievent *) event;
-(void) motioncancelled: (uieventsubtype) Motion withevent: (uievent *) event;
Remote control Events
-(void) Remotecontrolreceivedwithevent: (Uievent *) event;
Three, UIView touch event processing
UIView is a subclass of Uiresponder that can handle different touch events with the following 4 methods
One or more fingers start to touch the view, the system will automatically call the following method of view
-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event
One or more fingers moving on the view, the system automatically calls the view's following method (which continues to be called as the finger moves)
-(void) touchesmoved: (Nsset *) touches withevent: (Uievent *) event
One or more fingers to leave the view, the system will automatically call the following method of view
-(void) touchesended: (Nsset *) touches withevent: (Uievent *) event
A system event, such as a phone call, interrupts the touch process before the touch is finished, and the system automatically calls the following method of view
-(void) touchescancelled: (Nsset *) touches withevent: (Uievent *) event
Tip: Uitouch objects are stored in the touches
One, the event in iOS can be divided into 3 major types