2

デフォルトでは、マップ ビューにユーザーの位置を表示できます。注釈ピンをタップすると、「現在地」が表示されます。しかし、ユーザーの住所を通り、都市、国として表示したいと思います。CLGeoCoderクラスを使用してそれを行うにはどうすればよいですか?

4

1 に答える 1

6

次のようにします。

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

于 2012-01-19T19:06:08.720 に答える