gpt4 book ai didi

iphone - iOS CoreLocation 高度

转载 作者:技术小花猫 更新时间:2023-10-29 11:01:32 25 4
gpt4 key购买 nike

在 iOS 4.0 之前,CoreLocation 会正确报告高度,现在它始终报告为 0 英尺。

-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation *)oldLocation 
{
NSString *tLatitude = [NSString stringWithFormat:@"%3.5f", newLocation.coordinate.latitude];
NSString *tLongitude = [NSString stringWithFormat:@"%3.5f", newLocation.coordinate.longitude];
/* the following returns 0 */
NSString *tAltitude = [NSString stringWithFormat:@"%i", newLocation.altitude];

/* theres more code, but it's not relevant,
and this worked prior to iOS 4.0*/
[manager stopUpdatingLocation];
}

无法在设备或模拟器上运行,其他人是否遇到过此问题?

最佳答案

如果您使用的是 startMonitoringSignificantLocationChanges,这是 iOS 4.0 的一项新功能,那么您将不会获得海拔高度更新。这种低功耗模式仅使用手机信号塔来确定用户的位置,并且这种方法不报告高度。

更一般地说,iPhone 可以通过三种方式确定您的位置——手机信号塔、Wi-Fi 和 GPS。您只会在使用 GPS 时获得高度。因此,即使您将 desiredAccuracy 设置得非常精确以强制设备使用 GPS,如果用户在室内,iPhone 也可能无法获得 GPS 信号并会回退到手机或无线网络。在这种情况下,您将无法获得海拔高度。还要考虑使用 iPod Touch 的用户——它只能通过 Wi-Fi 获取位置,因此也不会报告高度。

关于iphone - iOS CoreLocation 高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4870480/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com