2011-01-26 87 views
3

我正在嘗試爲地圖創建自定義註釋。我遇到的問題是,我無法使註釋一個接一個地下降。所有引腳同時下降。這是didAddAnnotations的委託代碼。您能否幫我重寫代碼,以便我可以使自定義註釋一個接一個地放下......就像我們使用默認註釋時發生的那樣。提前致謝....!!!!MapView自定義註釋掉落

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

你可以添加變得更長一點在循環的每次迭代中,這樣的延遲:

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; 
} 
+0

由於一噸。有用...!!!! – bp581 2011-01-26 19:47:37