Objective C: Detecting a shake
问题 I'm using the shake api like this: - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { if (event.subtype == UIEventSubtypeMotionShake) { [img stopAnimating]; } } How do I detect that the shaking has stopped? 回答1: You are on the right track, however, there are still more things you need to add to detect shaking: You can test this by adding an NSLog to the motionBegan or motionEnded methods, and in the Simulator, press CONTROL + COMMAND + Z #pragma mark - Shake Functions -