我正在使用mkmapview并在其上放针脚。我希望别针一一掉下来,而不是同时掉下来。本来我打电话

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


其中dropTime是每个引脚的不同延迟,而dropPin是使引脚掉线的一种方法。不幸的是,这背后的多线程似乎导致崩溃。

有谁知道更好的方法?

最佳答案

如果您的目标是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
                            }
                         }];
}

关于iphone - iphone mapkit:别针一一掉下来,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3385038/

10-10 20:30