Как изменить вид, пока мы касаемся любой аннотации - PullRequest
1 голос
/ 20 марта 2012

Я хочу добавить функциональность в MKMapView.

У меня есть mapView со многими аннотациями, теперь я хочу это ... когда я касаюсь любой аннотации, весь вид должен быть сосредоточен на этой аннотации.т.е. аннотация A находится в верхнем правом углу, и когда я касаюсь этого, MapView должен показать, что A в центре.

Ответы [ 2 ]

4 голосов
/ 20 марта 2012
- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
   MKAnnotation *annotation= view.annotation;  // Get your annotaion here
   [map setCenterCoordinate:annotation.coordinate];  
}

//This will set the annotation in the centre of the map without zooming the map.
3 голосов
/ 20 марта 2012

В Annotation Delegate вы должны установить регион для просмотра карты, указав центр

- (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{
   MKAnnotation *annotation= view.annotation;  // Get your annotaion here
   MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };
   region.center.latitude=annotation.coordinate.latitude;
   region.center.longitude=annotation.coordinate.longitude;
   region.span.latitudeDelta=0.001f;
   region.span.longitudeDelta=0.001f;
   [mapView setRegion:region animated:YES];
  //Do your other stuffs here
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...