0

我已经实现了如下所示的代码。我想添加具有下降效果的动画。但是,一旦我输入 pinView.animatesDrop 就无法识别!我无法弄清楚我做错了什么?

 - (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation {
       MKAnnotationView *pinView=nil;
        if(![annotation isKindOfClass:[Annotation class]]) // Don't mess user location
            return nil;

    static NSString *defaultPinID = @"StandardIdentifier";
    pinView = (MKAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID];
    if (pinView == nil){
        pinView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:defaultPinID];

    }

    // Build our annotation
    if ([annotation isKindOfClass:[Annotation class]]) {
        Annotation *a = (Annotation *)annotation;

        pinView.image = [ZSPinAnnotation pinAnnotationWithColor:a.color];// ZSPinAnnotation Being Used
        pinView.annotation = a;
        pinView.enabled = YES;
        pinView.centerOffset=CGPointMake(6.5,-16);
        pinView.calloutOffset = CGPointMake(-11,0);
            //pinView.animatesDrop = YES;


    }

    pinView.canShowCallout = YES;
    UIButton *rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    [rightButton setTitle:annotation.title forState:UIControlStateNormal];
    [pinView setRightCalloutAccessoryView:rightButton];
    pinView.leftCalloutAccessoryView = [[UIView alloc] init];
    pinView.leftCalloutAccessoryView=nil;

    /*UIButton *leftButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
    [leftButton setTitle:annotation.title forState:UIControlStateNormal];
    [pinView setLeftCalloutAccessoryView:leftButton];*/
    return pinView;
}
4

2 回答 2

6

您的“pinView”是一个MKAnnotationViewanimatesDrop仅与相关联MKPinAnnotationView。因此它不识别。MKPinAnnotationView如果您希望注释随动画一起下降,则需要将注释更改为 a 。

希望能帮助到你

于 2012-11-08T04:57:30.327 回答
-1

用这个

 Objanno.animatesDrop = YES;
于 2017-02-22T11:55:34.553 回答