//引头文件
#import "AppDelegate.h"
//成为第一响应者
- (void)viewDidLoad
{
[super viewDidLoad];
[[UIApplication sharedApplication] setApplicationSupportsShakeToEdit:YES];
[self becomeFirstResponder];
}
//实现方法
//检测到摇动
- (void) motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"dong");
UIAlertView * asd = [[UIAlertView alloc]initWithTitle:@"sd" message:@"dfs" delegate:self cancelButtonTitle:@"dfdfs" otherButtonTitles:@"dsddsdff", nil];
[asd show];
}
//摇动取消
- (void) motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
NSLog(@"ting");
}
//摇动结束
- (void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (event.subtype == UIEventSubtypeMotionShake) {
NSLog(@"tingle");
}
}