I just created a function to shake the iOS device and trigger some experience. Now I searched the internet and read the development documentation. I feel that there are too many bad articles on the Internet, there are also a lot of articles that are reproduced and copied blindly, and the Implementation Principles have not yet been clarified. Instead of having to go online for time-consuming searches, it is better to take a look at the development documentation and quickly solve the problems that need to be solved. Specific implementation method: the iOS SDK has easily integrated the shake event, Just Like triggering the touch event. It should be noted that the current ViewController is set to the first responder first, then, when the app has a shake event, the program will automatically execute-(void) motionCancelled :( UIEventSubtype) motion withEvent :( UIEvent *) event-(void) motionBegan :( UIEventSubtype) motion withEvent :( UIEvent *) event-(void) motionEnded :( UIEventSubtype) motion withEvent :( UIEvent *) the event only needs to write the required functions in the corresponding trigger event. Code: set the first responder: [cpp]-(BOOL) canBecomeFirstResponder {return YES;}-(void) viewDidAppear :( BOOL) animated {[self canBecomeFirstResponder];} process the trigger Event: [cpp] # pragma mark-MotionShake event-(void) motionBegan :( UIEventSubtype) motion withEvent :( UIEvent *) Event {}-(void) motionEnded :( UIEventSubtype) motion withEvent :( UIEvent *) event {if (motion = UIEventSubtypeMotionShake) {NSLog (@ "Shake !!!!! !!!!!! ") ;}}-(Void) motionCancelled :( UIEventSubtype) motion withEvent :( UIEvent *) event {}