MapView Annotation Mark

I am trying to create a custom annotation for a map. I have a problem: I cannot record annotations one by one. All pins drop out simultaneously. Here is the delegate code for didAddAnnotations. Can you help me rewrite the code so that I can turn off user annotations one by one. It just happens when we use default annotations. Thanks in advance....!!!!

- (void) mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views {

    CGRect visibleRect = [mapView annotationVisibleRect]; 

    for (MKAnnotationView *view in views) {
        CGRect endFrame = view.frame;

        CGRect startFrame = endFrame;
        startFrame.origin.y = visibleRect.origin.y - startFrame.size.height;
        view.frame = startFrame;

        [UIView beginAnimations:@"drop" context:NULL]; 
        [UIView setAnimationDuration:1];

        view.frame = endFrame;

        [UIView commitAnimations];
    } // end of for 
} // end of delegate
+3
source share
1 answer

You can add a delay that will be slightly larger at each iteration of your loop, for example:

double delay = 0.0;
for (MKAnnotationView *view in views) {
    CGRect endFrame = view.frame;
    CGRect startFrame = endFrame;
    startFrame.origin.y = visibleRect.origin.y - startFrame.size.height;
    view.frame = startFrame;
    [UIView beginAnimations:@"drop" context:NULL];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationDelay:delay];
    view.frame = endFrame;
    [UIView commitAnimations];
    delay += 0.1;
}
+3
source

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


All Articles