I think that I just fix the initial value of UIAcceleration y and compare it with the current value and then โmeasureโ, but I donโt know if (1) (2) is correct what this mathematics should be.
Thanks for any help.
Update:
Here is the code I used as jrturton suggested.
#import "ViewController.h" @interface ViewController() { CMMotionManager *motionManager; } @end @implementation ViewController @synthesize angleLabel; - (void)startMotion { if (motionManager == nil) { motionManager = [[CMMotionManager alloc] init]; } motionManager = [[CMMotionManager alloc] init]; [motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) { angleLabel.text = [NSString stringWithFormat:@"%g", motion.attitude.pitch]; }]; } - (void) stopMotion { if (motionManager) { [motionManager stopDeviceMotionUpdates]; } motionManager = nil; } - (void)viewDidUnload { [self setAngleLabel:nil]; [super viewDidUnload]; } @end
source share