사용자가지도를 스크롤 할 수있는 MKMapView가 있습니다. 나중에지도 중심에서 위도와 경도를 가져오고 싶지만 쉽게 할 수는 없습니다. 현재로서는 다음과 같은 것을 시도하고 있습니다.MKMapView지도의 중심을 얻는 방법은 무엇입니까?
CLLocationCoordinate2D centre = [locationMap convertPoint:locationMap.center toCoordinateFromView:locationMap];
txtLatitude.text = [NSString stringWithFormat:@"%f",centre.latitude];
txtLongitude.text = [NSString stringWithFormat:@"%f",centre.longitude];
위도와 경도 모두 0으로 표시됩니다. 누구나 가질 수있는 아이디어에 감사드립니다!
============== - 업데이트 1-
오. 아래에 제안 된대로 :
NSLog(@"%@", locationMap);
줄을 추가하면 로그에 "(null)"이 표시됩니다. 내가 (다른 것들 사이에) 내 헤더에 다음과 같은있어 :
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
IBOutlet MKMapView *locationMap;
@property (nonatomic, retain) IBOutlet MKMapView *locationMap;
과 내 방법 파일에 다음
@synthesize locationMap;
이것은 현재 경고 나 오류없이 컴파일된다. 내가 뻔한 것을 놓친 적이 있는지 궁금해하기 시작한거야?
내가 너무 것을 시도했습니다). – Haydn
locationMap은 유효한 포인터입니까? __NSLog (@ "% @", locationMap);는 무엇을 말합니까? – deanWombourne
감사합니다 - 로그는 "(null)"을 제공합니다 - 위의 업데이트를 참조하십시오. – Haydn