OCmapView不会显示群集/注释?

时间:2013-12-29 17:49:28

标签: mkmapview mapkit mkannotationview

今天我开始使用OCMapView(https://github.com/yinkou/OCMapView)并研究了示例项目......所以我决定将内容添加到我的项目中...每件事都没有红色错误......模拟器转了打开并且没有任何事情只发生警报消息“你想使用当前位置吗?”然后黑屏显示它接缝它没有真正加载应用程序...我试图找出问题所在小时......所以也许你知道问题出在哪里......

@implementation AirportsViewController

- (void)viewDidLoad {


[OCMapView class];



mapView.delegate = self;

NSArray* airports = [Airport allAirports];


[mapView addAnnotations:airports];
[mapView setVisibleMapRect:MKMapRectWorld];
}

 -(MKAnnotationView*)mapView:(MKMapView *)aMapView viewForAnnotation:(id<MKAnnotation>)annotation {MKAnnotationView *annotationView;
static NSString* reuseIdentifier = @"airportAnnotation";
if ([annotation isKindOfClass:[OCAnnotation class]]) {

    OCAnnotation *clusterAnnotation = (OCAnnotation *)annotation;

    annotationView = (MKAnnotationView *)[aMapView dequeueReusableAnnotationViewWithIdentifier:@"ClusterView"];
    if (!annotationView) {
        annotationView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"ClusterView"];
        annotationView.canShowCallout = YES;
        annotationView.centerOffset = CGPointMake(0, -20);
    }


    clusterAnnotation.title = @"Cluster";
    clusterAnnotation.subtitle = [NSString stringWithFormat:@"Containing annotations: %d", [clusterAnnotation.annotationsInCluster count]];

    // set its image
    annotationView.image = [UIImage imageNamed:@"regular.png"];

        clusterAnnotation.title = clusterAnnotation.groupTag;

}
   else if ([annotation isKindOfClass:[Airport class]]) {
    MKAnnotationView* annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:reuseIdentifier];
    if (!annotationView) {
        annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseIdentifier] autorelease];
        annotationView.canShowCallout = YES;
    }
    annotationView.image = ((Airport*)annotation).icon;
    return annotationView;
} 

}

如果有什么不清楚的地方,或者我忘了要发布的一些代码,只是问一下。

0 个答案:

没有答案