3

私は mkmapview を使用しており、ピンをドロップしています。ピンが一斉に落ちるのではなく、1本ずつ落ちてほしいです。もともと電話してた

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

ここで、dropTime はピンごとに異なる遅延であり、dropPin はピンをドロップさせる方法でした。残念ながら、この背後にあるマルチスレッドがクラッシュを引き起こすようです。

誰かがより良い方法を知っていますか?

4

1 に答える 1

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
                            }
                         }];
}
于 2010-08-31T02:51:38.040 に答える