我正在编写一个使用 GPS 的应用程序。我可以成功获取纬度、经度和其他属性,但高度似乎总是返回“0.00”我有以下代码以最简单的方式对其进行测试,仍然得到 0.00。下面的代码:
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
{
// Stop updating location if renewed in less than 60 seconds
if ([self timeBetweenLocationandNow] < 60)
{
[locationManager stopUpdatingLocation];
NSLog(@"GPS Stopped");
}
NSLog(@"Altitude:%.2f m",newLocation.altitude);
}
关于什么可能是错的任何想法?同样在初始化方法上,我有以下内容:
- (id)init
{
self = [super init];
if (self != nil)
{
// Create location manager Object
locationManager = [[CLLocationManager alloc] init];
// Set the delegate to this object
[locationManager setDelegate:self];
// Set distance filter and accuracy
[locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
[locationManager startUpdatingLocation];
}
return self;
}
将欣赏任何见解。谢谢你