Touches, motion touch Event Response, touchesmotion
// Method to override the touch Event Response
1 // trigger this method (message sending) during touch 2-(void) touchesBegan :( NSSet <UITouch *> *) touches withEvent :( UIEvent *) event {3 UITouch * touch = [touches anyObject]; 4 CGPoint point = [touch locationInView: self. rootView. touchView]; // locationInView: obtains the coordinates of position 5 NSLog (@ "Touch start: %. 2f, %. 2f ", point. x, point. y); 6} 7 // trigger this event when the touch moves 8-(void) touchesMoved :( NSSet <UITouch *> *) touches withEvent :( UIEvent *) event {9 10 UITouch * touch = [touches anyObject]; 11 CGPoint point1 = [touch locationInView: self. rootView. touchView]; 12 CGPoint point2 = [touch previuslocationinview: self. rootView. touchView]; // previouslocationInView: obtains the coordinates of the previous vertex in the specified view. 13} 14 // This method is triggered when the touch ends (message sending) 15-(void) touchesEnded :( NSSet <UITouch *> *) touches withEvent :( UIEvent *) event {16 NSLog (@ "Touch end"); 17} 18 // in other cases, if you call or quit unexpectedly, run this method 19-(void) touchesCancelled :( NSSet <UITouch *> *) touches withEvent :( UIEvent *) event {20 21}
// Rewrite the method for mobile phone shake implementation
1 // call 2-(void) motionBegan :( UIEventSubtype) motion withEvent :( UIEvent *) event {3 NSLog (@ "Shake start "); 4} 5 // call 6-(void) motionEnded :( UIEventSubtype) motion withEvent :( UIEvent *) event {7 NSLog (@ "Shake end "); 8} 9 // call 10-(void) motionCancelled :( UIEventSubtype) motion withEvent :( UIEvent *) event {11 NSLog (@ "unexpectedly quit"); 12}