简体   繁体   English

为什么我将高度设为0

[英]Why I am getting the altitude as 0

为什么在使用CoreLocation框架时将海拔高度设为0?

try this 尝试这个

    - (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
    {
   altitudeLabel.text = [NSString stringWithFormat: @"%.2f m",   newLocation.altitude];
     }

Assuming you are testing your application on your device, the altitude will always be 0 when the update comes from Wi-Fi. 假设您正在设备上测试应用程序,则当更新来自Wi-Fi时海拔高度将始终为0。 Try disabling Wi-Fi to force an update from 3G. 尝试禁用Wi-Fi以强制从3G更新。 Note that it may take a while until you get an update because 3G doesn't return a position as fast as Wi-Fi. 请注意,由于3G的返回速度不如Wi-Fi快,因此可能需要一段时间才能获得更新。

Altitude comes from GPS. 高度来自GPS。 You need to be outdoors to get altitude. 您需要在户外才能获得高度。 Take your device outdoor and see if you are getting altitude. 将您的设备带到户外,看看您是否正在上升。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM