Touch events, gesture recognition, shaking events, etc. in iOS

Source: Internet
Author: User

In iOS, events can be categorized into the following categories:

1. Touch event: Trigger by touch, gesture (finger click, Zoom, etc.)

2. Motion event: triggered by an accelerator (e.g. mobile phone shake)

3. Remote Control event: triggered by other remote device (e.g. headphone control button)

Not all classes in iOS can handle receive and events, only objects that inherit from the Uiresponder class can handle events (such as our common UIView, Uiviewcontroller, uiapplication inherit from Uiresponder, They can both receive and handle events). The above three types of event-related processing methods are defined in Uiresponder:

Touch events:

Executes when one or more fingers begin to touch the screen;

-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event;

When one or more fingers are moved on the screen, note that this method repeats the call during the move;

-(void) touchesmoved: (Nsset *) touches withevent: (Uievent *) event;

One or more fingers touch the end to leave the screen to execute;

-(void) touchesended: (Nsset *) touches withevent: (Uievent *) event;

Touch when accidental cancellation occurs (for example, when you are touching the phone);

-(void) touchescancelled: (Nsset *) touches withevent: (Uievent *) event;

Motion Events:

Execution at the beginning of the campaign;

-(void) Motionbegan: (uieventsubtype) Motion withevent: (uievent *) event Ns_available_ios (3_0);

Execution after the end of the campaign;

-(void) motionended: (uieventsubtype) Motion withevent: (uievent *) event Ns_available_ios (3_0);

Execution when motion is canceled unexpectedly

-(void) motioncancelled: (uieventsubtype) Motion withevent: (uievent *) event Ns_available_ios (3_0);

Touch events, gesture recognition, shaking events, etc. in iOS

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.