我正在尝试为地图创建自定义注释。我遇到的问题是,我无法一个接一个地删除注释。所有引脚同时下降。这是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
答案 0 :(得分: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;
}