문제 설명
xcode의 맵킷에 있는 재설정 버튼 및 책갈피 버튼 (A Reset button and a bookmark button in mapkit in xcode)
현재 mapkit과 관련된 애플리케이션을 개발 중입니다. 프로그램을 열 때 보기를 기본 보기로 재설정하는 재설정 버튼을 보기에 추가하고 싶습니다. 더 나은 방법은 앱을 열고 닫을 때 맵킷이 자체적으로 재설정된다는 것입니다.
코드 다음과 같이 초기 영역을 설정하는 데 사용했습니다:
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = 54.049929;
region.center.longitude = ‑4.54834;
region.span.longitudeDelta = 4.5;
region.span.latitudeDelta = 4.5;
[mapView setRegion:region animated:YES];
도움을 주시면 감사하겠습니다.
참조 솔루션
방법 1:
Store the Location of your map In .h file
CLLocationCoordinate2D location;
When setting initial Region
location.latitude = 54.049929;
location.longitude = ‑4.54834;
In your Reset Button
MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
region.center.latitude = location.latitude
region.center.longitude = location.longitude;
region.span.longitudeDelta = 4.5;
region.span.latitudeDelta = 4.5;
[mapView setRegion:region animated:YES];
방법 2:
So, are you trying to figure out how to actually add the button to the view and link it to a method in the code?
The code itself within the method would just be the same as you used for your initial setup, as indicated by BuildSucceded above ...
You should just add a button to the toolbar/navbar(if you have one), and link it to a "resetMap()" method.