我發展與反向地理編碼的iOS應用功能根據這篇文章:geocoding tutorialCLGeocoder reverseGeocodeLocation返回「kCLErrorDomain錯誤9」
但是當我測試這樣的模擬器,我得到「kCLErrorDomain錯誤9」。我搜索了很多,唯一的錯誤0或1不是9
這裏是我的代碼中有viewDidLoad
:
self.locationManager = [[CLLocationManager alloc]init];
self.locationManager.delegate = self;
self.locationManager.distanceFilter = 80.0;
[self.locationManager startUpdatingLocation];
CLGeocoder *geocoder = [[[CLGeocoder alloc] init] autorelease];
[geocoder reverseGeocodeLocation:self.locationManager.location
completionHandler:^(NSArray *placemarks, NSError *error) {
NSLog(@"reverseGeocodeLocation:completionHandler: Completion Handler called!");
if (error){
NSLog(@"Geocode failed with error: %@", error);
return;
}
if(placemarks && placemarks.count > 0)
{
//do something
CLPlacemark *topResult = [placemarks objectAtIndex:0];
NSString *addressTxt = [NSString stringWithFormat:@"%@ %@,%@ %@",
[topResult subThoroughfare],[topResult thoroughfare],
[topResult locality], [topResult administrativeArea]];
NSLog(@"%@",addressTxt);
}
}];
非常感謝你。
模擬器現在返回錯誤8,而我什麼也沒有做到我的代碼。 – goofansu 2012-03-02 01:09:25
CLLocationManager,CLGeocoder不能在模擬器上工作。它僅在Device上進行調試或在設備上進行測試時顯示結果。在模擬器上它會顯示錯誤。 – 2012-10-16 05:50:45
這在我的iPhone 4設備上很有魅力。謝謝! – gstroup 2013-01-03 17:30:10