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