Firstly conform to <UIAccelerometerDelegate>
and then you can use these methods:
#pragma mark --- Acceleration Start and Stop ----------------------------
-(void)startMeasuringAcceleration{
NSLog(@"Started Measuring Acceleration");
[[UIAccelerometer sharedAccelerometer] setUpdateInterval:1];//update interval (1s at moment)
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
}
-(void)stopMeasuringAcceleration{
[[UIAccelerometer sharedAccelerometer] setDelegate:nil];
}
#pragma mark UIAcceleromete Delegate Methods-----------------------------------------------
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{
NSLog(@"%f, %f, %f, %f", acceleration.x, acceleration.y, acceleration.z, acceleration.timestamp);
}
Measure X, Y and Z. Z is the axis on the screen, Y top to bottom and X left to right.
In viewDidLoad call [self startMeasuringAcceleration]
to start
Hope that helps.