iOS Mapkit-注释在地图滚动/缩放时消失

iOS Mapkit-注释在地图滚动/缩放时消失,ios,annotations,hide,mapkit,Ios,Annotations,Hide,Mapkit,在初始加载时,注释显示得很好。但是如果我滚动地图,它们都会消失,代码只针对用户位置调用,而不是viewForAnnotation委托方法中的其他注释 图钉 -(void)viewDidLoad{ ...Download Coordinates and Data from Web here... [self.mapView addAnnotation:pin]; } 委托方法 - (MKAnnotationView *)mapView:(MKMapView *)mapView

在初始加载时,注释显示得很好。但是如果我滚动地图,它们都会消失,代码只针对用户位置调用,而不是viewForAnnotation委托方法中的其他注释

图钉

-(void)viewDidLoad{
     ...Download Coordinates and Data from Web here...
     [self.mapView addAnnotation:pin];
}
委托方法

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
    //Player's Pin
    if([annotation class] == MKUserLocation.class) {
        return nil;
    }

    //Cluster Pin
    if([annotation isKindOfClass:[REVClusterPin class]]){
        REVClusterPin *pin = (REVClusterPin *)annotation;
        if( [pin nodeCount] > 0 ){
            pin.title = @"___";

            MKAnnotationView *annotationView  = (REVClusterAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:@"cluster"];

            if( !annotationView ){
                annotationView = (REVClusterAnnotationView*)
                [[REVClusterAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"cluster"];
            }

            annotationView.image = [UIImage imageNamed:@"cluster.png"];

            [(REVClusterAnnotationView*)annotationView setClusterText:
             [NSString stringWithFormat:@"%i",[pin nodeCount]]];

            annotationView.canShowCallout = NO;
            return annotationView;
        }
    }
    //Player Pin
    if([annotation isKindOfClass:[ZEPointAnnotation class]]){
        ZEPointAnnotation *pin = (ZEPointAnnotation *)annotation;
        MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"pin"];
        if(!annotationView){
            annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"pin"];
        }
        annotationView.canShowCallout = YES;
        annotationView.draggable = NO;

        ...Create Pin Data Here...

        return annotationView;
    }
    return nil;
}

删除动画。这将解决您的问题

删除动画。这将解决您的问题

尽管有以下两个观察结果,我仍然怀疑问题是否存在于其他地方。尝试暂时注释此viewForAnnotation方法。用户位置信标现在可以工作了吗?如果没有其他功能,则应该具有If[annotation iskindof class:[MKUserLocation class]]。您真的不应该使用相等运算符测试类,特别是因为您不确定iOS在后台可能不会进行某些子类化。我不认为这是问题所在,因为它应该最终返回零;,但是只是一个observation.BTW,如果dequeueReusableAnnotationViewWithIdentifier成功返回了以前发布的MKAnnotationView,您是否设置了annotation属性?就我个人而言,如果!annotationView,我建议设置annotationView.annotation=annotation的and else子句@Rob我注释掉了viewForAnnotation,它用默认的红色针脚映射了注释。但当滚动/缩放地图时,它们仍然会消失,并且用户位置会重新设置动画。我确实更新了Iskindof类检查,谢谢。最后,通过调用dequeReausable。。第一次加载时它将返回零。然后在该语句中创建annotationView。之后,它将返回已经创建的注释…除非我误解了什么?哦,还有同样的问题!如此令人沮丧……尽管有以下两个观察结果,我仍然怀疑问题是否存在于其他地方。尝试暂时注释此viewForAnnotation方法。用户位置信标现在可以工作了吗?如果没有其他功能,则应该具有If[annotation iskindof class:[MKUserLocation class]]。您真的不应该使用相等运算符测试类,特别是因为您不确定iOS在后台可能不会进行某些子类化。我不认为这是问题所在,因为它应该最终返回零;,但是只是一个observation.BTW,如果dequeueReusableAnnotationViewWithIdentifier成功返回了以前发布的MKAnnotationView,您是否设置了annotation属性?就我个人而言,如果!annotationView,我建议设置annotationView.annotation=annotation的and else子句@Rob我注释掉了viewForAnnotation,它用默认的红色针脚映射了注释。但当滚动/缩放地图时,它们仍然会消失,并且用户位置会重新设置动画。我确实更新了Iskindof类检查,谢谢。最后,通过调用dequeReausable。。第一次加载时它将返回零。然后在该语句中创建annotationView。之后,它将返回已经创建的注释…除非我误解了什么?哦,还有同样的问题!太令人沮丧了。。。