默认情况下,在地图视图中,我们可以显示用户的位置。点击注释引脚时,它将显示"当前位置"。但我想把用户的地址显示为街道、城市和国家。如何使用CLGeoCoder
类来完成此操作?
这样做:
CLGeocoder *gc = [[[CLGeocoder alloc] init] autorelease];
[gc reverseGeocodeLocation:locationObject completionHandler:^(NSArray *placemark, NSError *error) {
CLPlacemark *pm = [placemark objectAtIndex:0];
NSDictionary *address = pm.addressDictionary;
// do something with the address, see keys in the remark below
}];
以及此处的相关文档:http://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLPlacemark_class/Reference/Reference.html#//apple_ref/occ/instp/CLPlacemark/addressDictionary