Displaying a leader after moving the map

I have several annotations on the map. With one selected (callout included), I want the map to focus on it. I call [mapView setCenterCoordinate:coordinate animated:YES];

in didSelectAnnotationView

to achieve this.

This works, but not always - mostly when there is not enough space left to display the leader, moving the map and highlighting the annotation, but the leader is not showing (it doesn't matter if it is animated or not), unless I move the map myself with setCenterCoordinate

, after selecting the annotation the map automatically moves (slightly) to display the leader and it works every time.

Any ideas how to get it to work in my case? To summarize, I want to focus the map on the selected annotation and show the leader.

+3


source to share


1 answer


I decided it, causing setCenter

a slight delay in didSelectAnnotationView

:



dispatch_time_t dt = dispatch_time(DISPATCH_TIME_NOW, 0.2 * NSEC_PER_SEC);
dispatch_after(dt, dispatch_get_main_queue(), ^(void)
{
    [mapView setCenterCoordinate:view.annotation.coordinate animated:YES];
});

      

+4


source







All Articles