Processing of touch events of UIResponder and UIView, uiresponderuiview

Source: Internet
Author: User

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.

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.