我正在使用下面指定的代码来获取高度值
-(void)awakeFromNib {
locmanager = [[CLLocationManager alloc] init];
[locmanager setDelegate:self];
[locmanager setDesiredAccuracy:kCLLocationAccuracyBest];
[locmanager startUpdatingLocation];
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
heightMesurement.text = [NSString stringWithFormat: @"%.2f m", newLocation.altitude];
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
{
heightMesurement.text = @"0.00 m";
}
当我打印heightMesurement.text时,didUpdateToLocation方法正在调用,我将高度值设为null。
任何人都可以让我知道为什么会发生这种情况以及如何纠正它。
感谢所有人, Monish。