3

我正在尝试为地图创建自定义注释。我遇到的问题是,我不能让注释一个接一个地下降。所有引脚同时下降。这是 didAddAnnotations 的委托代码。你能帮我重写代码,这样我就可以让自定义注释一个接一个地下降......就像我们使用默认注释时发生的那样。提前致谢....!!!!

- (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
4

1 回答 1

3

您可以在循环的每次迭代中添加一个更长的延迟,如下所示:

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;
}
于 2011-01-26T18:02:45.957 回答