#import "ViewController.h"@interfaceViewcontroller ()@end@implementationViewcontroller- (void) viewdidload {[Super viewdidload]; //additional setup after loading the view, typically from a nib.[[UIApplication sharedapplication] setapplicationsupportsshaketoedit:yes]; [Self becomefirstresponder]; }- (void) didreceivememorywarning {[Super didreceivememorywarning]; //Dispose of any resources the can be recreated.}-(BOOL) canbecomefirstresponder{returnYES;//default is NO}- (void) Motionbegan: (uieventsubtype) Motion withevent: (Uievent *)Event{NSLog (@"start shaking your phone");}- (void) motionended: (uieventsubtype) Motion withevent: (Uievent *)Event{NSLog (@"Stop"); Uialertview*yaoyiyao = [[Uialertview alloc]initwithtitle:@"Warm tips:"Message@"you shake your phone, what do you want? " Delegate: Self Cancelbuttontitle:@"CANCEL"Otherbuttontitles:nil]; [Yaoyiyao show];}- (void) motioncancelled: (uieventsubtype) Motion withevent: (Uievent *)Event{NSLog (@"Cancel");}@end
Shake a Shake