Turn from: http://www.jb51.net/article/102316.htm
The implementation of "Shake Shake" function:
The iphone has good support for "rocking", which is generally two steps:
Open the Accept "shake" switch in the view controller;
?
| 1 2 3 4 5 6 |
-(void) Viewdidload {//Set allow rocking function [uiapplication sharedapplication].applicationsupportsshaketoedit = YES; And let yourself be the first responder [self becomefirstresponder]; } |
Implement the functionality that needs to be implemented in the established method of "shaking" triggers ("shake" the detection method).
?
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22-23 |
Shake and start shaking-(void) Motionbegan: (uieventsubtype) Motion withevent: (uievent *) event {NSLog (@ "Start shaking"); Add "shake" animation [self addanimations]; Sound Audioservicesplaysystemsound (Soundid); |