1. Touch Event Type Touch Event Type A total of four, one full touch, including at least start and end of two events 1> touch begins with a finger (one or more root) on the screen 2> touch moves, the finger moves on the screen (which can happen) 3 > Touch ends, the finger leaves the screen 4> touch is canceled because a system event (such as a phone call) A touch event is canceled
#pragma Mark * * * Touch start
-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) event
#pragma Mark Touch Mobile
-(void) touchesmoved: (Nsset *) touches withevent: (Uievent *) event
#pragma mark Touch Done
-(void) touchesended: (Nsset *) touches withevent: (Uievent *) event
#pragma mark Touch Cancel (call)
-(void) touchescancelled: (Nsset *) touches withevent: (Uievent *) event
#pragma mark-common methods
#pragma mark gets any touch object in the touch collection, and for a single touch, you can use it directly.
Uitouch *touch = [touches anyobject];
#pragma mark gets the position of the touch in the current view
Cgpoint location = [Touch LocationInView:self.view];
#pragma mark gets touch at the previous point in the current view
Cgpoint prelocation = [Touch PreviousLocationInView:self.view];
2. Touch Object Uitouch Properties and Methods properties: 1> View: Views that detect touch events, use the most frequent properties in Development 2> window: windows, window with touch events 3> phase: Phase Properties , minimal use in development, general user-defined gesture recognition 4> timestamp: Two properties that occur over the time of the touch, typically user-developed custom gesture recognition that is not needed in daily development. 5> Tapcount: When touch occurs, the number of times a finger is clicked in a short time is usually used to determine whether to click or double-tap the hint: in iOS development, try to use as few double-click events as possible! If you want to use a double-click, you need a graphical interface to prompt the user, one of the controls is allowed double-click operation. Method: 1> Locationinview: The location of the touch event relative view (coordinate point) 2> Previouslocationinview: The position of the finger before the touch event (coordinate point) 3. For single touch, often use uitouch *touch = [touches anyobject]; Fetching a user's touch object from the touches collection generally, in application development, in order to simplify the complexity of the program, it is generally only a single touch, and if the need to support multi-touch, often using gesture recognition to handle. 4. HitTest method for detecting specific responses to user touch Point views-(UIView *) HitTest: (cgpoint) points withevent: (Uievent *) event with-(BOOL) pointins IDE: (cgpoint) point withevent: (Uievent *) event; Returns yes within the view, otherwise returns no joint use to determine whether the location of the user's touch point is within the specified view, or, if so, indicates that the view can receive user interaction. The above two methods will be recursively recursive, multiple calls! Until you find the best view for responding to user requests! Tip: In general, do not rewrite these two methods easily, because once the method internal use of large consumption of code, will seriously affect the performance of the system! Tip: Once you have an example where you need to intercept a touch event, you can communicate with the artist or planner to adjust the interface! 1) If nil is returned, indicating that no response is in view 2) ifReturns a view that indicates that the view receives a user's response to receive a user's touch response in several conditions 1) self.userinteractionenabled = YES; Allow receive user response 2) Self.hidden = NO; Only realistic views can receive user Touch 3) self.alpha > 0.01; The transparency of the view must be visible tip: Not all controls receive user interaction by default, such as: Uiimageview,uilabel, and so on, points that point users touch, relative to the coordinate point of the current view coordinate system event user touch The general programmer is not used in the development of the event, which is used to pass on the responder chain
iOS Touch Event application Example