x y z
x围绕x轴摇动。y围绕y轴摇动。(加速计)
z围绕z轴摇动 (陀螺仪)
-(void) shakeDevice {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"你摇动手机了。。。" delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
[alert show];
}
-(BOOL) canBecomeFirstResponder {
return YES;
}
-(void) motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event {
if (event.type == UIEventSubtypeMotionShake) {
[self shakeDevice];
}
}