Ios implements the shake Function
You must have used the shake function ~ The ios SDK helped us complete all the work. We only need to add the corresponding logic.
The following is the implementation code (Add the following code to the corresponding ViewController ):
# Pragma mark-motion refresh-(BOOL) canBecomeFirstResponder {return YES;}-(void) motionBegan :( UIEventSubtype) motion withEvent :( UIEvent *) event {NSLog (@ start shaking ); audioServicesPlaySystemSound (kSystemSoundID_Vibrate); // vibration effect}-(void) motionEnded :( UIEventSubtype) motion withEvent :( UIEvent *) event {NSLog (@ end shaking);}-(void) motionCancelled :( UIEventSubtype) motion withEvent :( UIEvent *) event {NSLog (@ cancel );}
The following code adds the vibration effect when the shaking starts. You need to add the # import
AudioServicesPlaySystemSound (kSystemSoundID_Vibrate );