- (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
}
另外,locationManager:didUpdateToLocation:fromLocation:
方法可能在iOS6不可用。所以在iOS6以上版本你應該使用locationManager:didUpdateLocations: