ios CLLocationManager didUpdateToLocation纬度和经度迁移
我用这个代码得到经度和纬度ios CLLocationManager didUpdateToLocation纬度和经度迁移,ios,Ios,我用这个代码得到经度和纬度 (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { NSLog(@"%f",newLocation.coordinate.latitude); self.location = newLocation
(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation {
NSLog(@"%f",newLocation.coordinate.latitude);
self.location = newLocation;
}
但是我得到的经纬度与实际的地理位置有偏差。如何解决此问题?您应该测试返回的CLLocation对象的准确性,并确保它符合您的位置准确性标准
if (newLocation.horizontalAccuracy > 1000) {
// Throw away this location and wait for another one as this is over 1km away
}
此外,iOS6中已弃用了
locationManager:didUpdateLocation:fromLocation:
方法,因此如果您针对的是iOS6+,则应使用locationManager:didUpdateLocations:
。您应该测试返回的CLLocation对象的准确性,并确保它符合您的定位精度标准
if (newLocation.horizontalAccuracy > 1000) {
// Throw away this location and wait for another one as this is over 1km away
}
另外,iOS6中已经不推荐使用
locationManager:didUpdateLocation:fromLocation:
方法,因此如果您针对的是iOS6+,则应该使用locationManager:didUpdateLocations:
。我不理解这个问题。你能解释一下你在期待什么吗?我想知道经度和纬度。但它与实际地理位置有偏差。我怎样才能得到准确的位置?我不明白这个问题。你能解释一下你在期待什么吗?我想知道经度和纬度。但它与实际地理位置有偏差。如何获得准确的位置?您需要测试类是否支持使用respondsToSelector:
方法的方法-检查:获取更多信息。您需要测试类是否支持使用respondsToSelector:
方法的方法-检查:获取更多信息。