【发布时间】:2015-01-19 15:19:32
【问题描述】:
我怎样才能从 CLGeocoder 中获取所有值(国家、城市(重要)和通道),并且只使用英语并忽略设备的语言?
我的代码:
-(void)updateLocations
{
// Create a location manager
locationManager = [[CLLocationManager alloc] init];
// Set a delegate to receive location callbacks
locationManager.delegate = self;
// Start the location manager
[locationManager startUpdatingLocation];
// [self.locationManager requestWhenInUseAuthorization];
[locationManager requestAlwaysAuthorization];
}
-(void)updateLocationManager : (CLLocationManager *)manager
{
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:locationManager.location completionHandler:^(NSArray *placemarks, NSError *error)
{
if(placemarks && placemarks.count > 0)
{
CLPlacemark *placemark = [placemarks objectAtIndex:0];
NSString *country = placemark.country;
// Getting the City
NSString *city = placemark.addressDictionary[@"City"];
NSString *thoroughfare = [placemark thoroughfare];
}
else
{
NSLog(@"Geocode failed with error: %@", error);
return;
}
}];
}
【问题讨论】:
标签: ios objective-c geolocation