Loading

Monday, September 20, 2010

X,Y and Z Position of Device

1. include UIAccelerometerDelegate in .h file

2. Declare UIAccelerationValue acceleration[3]; in .h

3. [[UIAccelerometer sharedAccelerometer] setDelegate:self]; in ViewDidLoad or ViewWillAppear

4. - (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration
{
[self updateHistoryWithX:acceleration.x Y:acceleration.y Z:acceleration.z];
} // Delegate method

- (void)updateHistoryWithX:(float)x Y:(float)y Z:(float)z {

NSLog(@"X=%f Y=%f Z=%f ",x,y,z);
}

No comments:

Post a Comment