2010-08-02 44 views
3

我正在使用mkmapview並將針腳放到它上面。我希望銷子一個接一個倒下,而不是全部同時倒下。原來我打電話給iphone mapkit:有針腳一個接一個地掉落

[self performSelector:@selector(dropPin) withObject:nil afterDelay:dropTime]; 

其中dropTime是每個引腳的不同延遲,而dropPin是一種使引腳掉線的方法。不幸的是,這背後的多線程似乎會導致崩潰。

有誰知道更好的方法?

回答

3

如果你的目標的iOS4,塊來處理動畫,而無需擔心代表,回調,或選擇一個偉大的方式:

- (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { 
    if ([views count] == 0) { 
     return; 
    } 
    MKAnnotationView *aV; 
    for (aV in views) { 
     // set up pin beginning and end frames, shadow subview frame and center 

     [UIView animateWithDuration:0.75 
           delay:(0.0 + [views indexOfObject:aV]/10.0) 
          options:UIViewAnimationOptionCurveEaseOut 
         animations:^{ 
          [aV setFrame:endFrame]; 
          // animate the shadow subview's center point 
         } 
         completion:^ (BOOL finished) { 
          if (finished) { 
           // do something here when the animation finished 
          } 
         }]; 
} 
+0

這將是巨大的,有一個iOS的3兼容的解決方案。 – samvermette 2010-10-06 17:37:19