Mapkit how to detect annotations loaded

I want the annotation popup to pop up when the pin has finished this animation. Currently, I can simulate it in the following way:

- (void)showCallOut {
    [myMapView selectAnnotation:[myMapView.annotations objectAtIndex:0] animated:YES];
}

In my viewDidLoadthere is my annotation created

    [myMapView addAnnotation:annotation];

The problem is that after that you simply cannot call [self showCallOut];because at runtime it answers before MapKit "confirms" the annotation reduction. I need to either create a delay (I would like to avoid this) or find the correct way to detect when the annotations are in place, and then run the method showCallOut.

Thanks for any help!

Thanks to aBitObvious below for providing the solution:

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {
    [self performSelector:@selector(showCallOut) withObject:nil afterDelay:1];
}
+3
1

didAddAnnotationViews:

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    [self showCallOut];
}

, .

Edit:
, ( ​​1/2 ):

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views
{
    [self performSelector:@selector(showCallOut) withObject:nil afterDelay:0.5];
}
+5

Source: https://habr.com/ru/post/1772767/


All Articles