Altitude problem IOS

末鹿安然 提交于 2019-12-06 14:17:56

问题


I have a problem in getting the altitude , it returns 0.0000 . Here is my code:

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation {
NSString *tAltitude  = [NSString stringWithFormat:@"%f", [newLocation altitude]];
CLLocationCoordinate2D coord=newLocation.coordinate;
MKCoordinateSpan span = {.latitudeDelta =  0.005, .longitudeDelta =  0.005};
MKCoordinateRegion region = {coord, span};
[map setRegion:region];
NSLog(@"Location: %@", [newLocation description]);
NSLog(@"altitudine:%@",tAltitude); }

回答1:


If you are indoor, iPhone uses cell tower, or WIFI location. These location will not return altitude. You have to test outdoor to get GPS.

To make sure that you are using GPS, check the horizontal accuracy as well. If it is in the range of 2 digits, you should be on GPS, and most likely you will get altitude reading



来源:https://stackoverflow.com/questions/5788328/altitude-problem-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!