I am trying to create a custom annotation for the map. The problem I have is , I can't make the annotation drop one after the other. All pins drop down at the same time. Here is the delegate code for didAddAnnotations. Can you help me to rewrite the code so that I can make the custom annotations drop one after the other..just like it 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
You could add a delay that becomes a little longer in each iteration of your loop, like this:
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;
}