大佬教程收集整理的这篇文章主要介绍了ios – iPhone模拟器上的海拔高度始终为零,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (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]; }
我的错误在哪里?
确定高度需要具有GPS功能的设备,并且您还需要在该设备上使用GPS才能获得它(即使在支持GPS的设备上,仅wifi位置也不会正确报告高度). iOS模拟器没有这些功能,因此高度不准确.您需要使用带有GPS的真实设备来获取高度测量值.
如果要模拟具有高度的CLLOCATIOn,可以创建CLLOCATIOn对象并自行传递高度:
- (id)initWithCoordinate:(CLLOCATIOnCoordinate2D)coordinate altitude:(CLLOCATIOnDistancE)altitude horizontalAccuracy:(CLLOCATIOnAccuracy)hAccuracy verticalAccuracy:(CLLOCATIOnAccuracy)vAccuracy timestamp:(NSDate *)timestamp
Altitude是一个只读属性,因此您需要自己创建一个新的CLLOCATIOn对象,而不是在委托回调中收到CLLOCATIOn对象时手动更改它.
以上是大佬教程为你收集整理的ios – iPhone模拟器上的海拔高度始终为零全部内容,希望文章能够帮你解决ios – iPhone模拟器上的海拔高度始终为零所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。