本文介绍了iOS Mapkit - 地图滚动/缩放时注释消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

On initial load, the annotations show just fine. But if I scroll the map, they all disappear and the code is only called for the user location, not the other annotations in the viewForAnnotation delegate method.

图钉

-(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;
}

推荐答案

移除动画.这将解决您的问题

remove animations. that will solve your problem

这篇关于iOS Mapkit - 地图滚动/缩放时注释消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:36