IOS touch events

Source: Internet
Author: User

There are four statuses of touch events.

 

-(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event

-(Void) touchesMoved :( NSSet *) touches withEvent :( UIEvent *) event;

// This method will be called repeatedly during finger movement

-(Void) touchesEnded :( NSSet *) touches withEvent :( UIEvent *) event;

-(Void) touchesCancelled :( NSSet *) touches withEvent :( UIEvent *) event;

 

Ps: a complete touch event must contain at least start and end

 

Properties of a touch object

1> view where a touch event occurs

2> window in which a touch event occurs

3> phase attribute for custom gestures

4> time when the timestamp is touched

// 3 and 4 are rarely used in actual development and are usually used for custom gestures.

5> tapCount the number of connections in a short period of time when a touch occurs

 

Common Methods for touching objects:

1> locationInView: When a view is passed in, the returned value is the position of the touch point on The view.

2> previuslocationinview: Position of the last click in a view

3> UITouch * touch = [touches anyObject]

 

Multi-touch Processing

First, you need to set the view to allow multi-touch

[View setMultipleTouchEnabled: YES];

View: You need to set a view that allows multi-touch

In actual application process

You need to process each touch object in the touches set separately during processing.

 

Because touches is an NSSet, the sequence of touch objects taken out during multi-point touch cannot be fixed. However, during a touch event, the view does not call the touchesEnded: method and touchesCancelled: the touch sequence in touches remains unchanged before the two methods.

Sample Code:

Http://dl.vmall.com/c01at1z0hp

Related Article

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.