iOS 陀螺仪


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];
}
}

posted @ 2013-04-25 13:05  javawebsoa  Views(168)  Comments(0Edit  收藏  举报