Using my 6+, I am trying to read relative altitude and pressure using the new CMAltimeter from CoreMotion. However, the callback never works. I have a very similar setup, which instead uses accelerometers, gyroscopes, and magnetometers. They all work fine.
I wonder if anyone managed to get a reading?
- (void)viewDidLoad {
[super viewDidLoad];
if([CMAltimeter isRelativeAltitudeAvailable]){
CMAltimeter *altimeterManager = [[CMAltimeter alloc]init];
[altimeterManager startRelativeAltitudeUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMAltitudeData *altitudeData, NSError *error) {
NSString *data = [NSString stringWithFormat:@"Altitude: %f %f", altitudeData.relativeAltitude.floatValue, altitudeData.pressure.floatValue];
NSLog(@"%@", data);
self.altimeterLabel.text = data;
}];
NSLog(@"Started altimeter");
self.altimeterLabel.text = @"-\n-";
} else {
NSLog(@"Altimeter not available");
}
}
I tried it fast, but there is only one height story to lose / win here.
source
share