One, the event in iOS can be divided into 3 major types

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.