2011-10-27 3 views
2

저는 아이폰 개발에 새로운 사람입니다. 현재 사용자가 2 초 동안 화면을 두드리고 사용자 위치 이름을 얻을 때 좌표 (위도/경도)를 가져와야하는 응용 프로그램을 개발하는 데 문제가 있습니다. 좌표가 있습니다. 그러나 나는 사용자가 태핑 한 사용자 위치 이름을 얻을 수 없습니다. 친절하게 저를 도와 주시겠습니까?iphone에서 mapkit을 사용하여 위치 이름을 얻는 방법은 무엇입니까?

+0

어떻게 이름을 정의하는? 주소? 상인? –

+0

학교에 가볍게 두드리는 것처럼 현재 위치 이름이 필요합니다. 응답으로 나는 그 특정 학교 이름을 얻습니다. 가능합니까? 어떻게 할 수 있니? – Aleem

답변

1

iOS 5+에서는 CLGeocoder 및 그 reverseGeocodeLocation:completionHandler: 방법을 사용합니다.

귀하의 경우 아마도 areasOfInterest 속성에 가장 관심이있을 것입니다.

예 :

CLGeocoder* gc = [[CLGeocoder alloc] init]; 
double lat, lon; // get these where you will 
[gc reverseGeocodeLocation:[[CLLocation alloc] initWithLatitude:lat longitude:lon] completionHandler:^(NSArray *placemarks, NSError *error) { 
    for (CLPlacemark* place in placemarks) { 
     if (place.region) 
      NSLog(@"%@", place.region); 
     // throroughfare is street name, subThoroughfare is street number 
     if (place.thoroughfare) 
      NSLog(@"%@ %@", place.subThoroughfare, place.thoroughfare); 
     for (NSString* aoi in place.areasOfInterest) 
      NSLog(@"%@", aoi); 
    } 
}]; 
관련 문제