IOS How to using UIAccelerometer

//Somewhere in initialization
UIAccelerometer *accel = [UIAccelerometer sharedAccelerometer];
accel.delegate = self;
accel.updateInterval = 1.0f/10.0f;

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
if (fabsf(acceleration.x) > kAccelerationThreshold || fabsf(acceleration.y) > kAccelerationThreshold || fabsf(acceleration.z) > kAccelerationThreshold) {
NSLog(@"Shaking!!!");
}
}

Comments

Popular posts from this blog

Java : Variables Declaring

SQL Self JOIN