//引頭文件
#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");
}
}