在 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 信号,并会退回到手机或 Wi-Fi。在这种情况下,您将无法获得高度。还要考虑使用 iPod Touch 的用户——它只能通过 Wi-Fi 获取位置,因此也不会报告海拔高度。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)