小编ema*_*zzi的帖子

iPhone模拟器上的海拔高度始终为零

我正在尝试在Xcode和Simulator上开发一个高度计,但它总是在海面以上的高度返回0.我不明白为什么,我已经在模拟器上尝试了很多地方.

我的代码是这样的:

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    _mapView.delegate = self;
    _locationManager = [[CLLocationManager alloc] init];
    _locationManager.desiredAccuracy = kCLLocationAccuracyBest;
    _locationManager.pausesLocationUpdatesAutomatically = YES;
    _locationManager.delegate = self;

    firstLocation = YES;
   checkUserLocation = NO;
}

- (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
CLLocation *location = [locations lastObject];
lastLocation = location.coordinate;
_latitudeLabel.text = [NSString stringWithFormat:@"Current latitude: %f", location.coordinate.latitude];
_longitudeLabel.text = [NSString stringWithFormat:@"Current longitude: %f", location.coordinate.longitude];
_altitudeLabel.text = [NSString stringWithFormat:@"Current altitude: %f m", location.altitude];
}
Run Code Online (Sandbox Code Playgroud)

我的错误在哪里?

gps cocoa-touch cllocationmanager ios ios-simulator

5
推荐指数
1
解决办法
2330
查看次数

标签 统计

cllocationmanager ×1

cocoa-touch ×1

gps ×1

ios ×1

ios-simulator ×1