iOS: How to Implement a “Shake Device” event?
问题 I want to a "Shake Device" event to my app - i.e., when the user shakes the device something happens. I tried implementing: -(void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.subtype == UIEventSubtypeMotionShake) { //something happens } } It doesn't seem to work....... Does anyone knows which method I should use? 回答1: Try using the below code, it worked fine for me. - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if ( event.subtype ==