Mkmapview OCmapView赢得';不显示群集/注释?
今天我开始使用OCMapView()并研究了示例项目。。。所以我决定将内容添加到我的项目中。。。一切正常没有红色错误。。。模拟器打开了,什么也没发生,只有一条警告消息显示“你想使用当前位置吗?”然后黑屏显示,这样它就不会真正加载应用程序了。。。我花了几个小时试图解决这个问题。。。所以也许你知道问题在哪里Mkmapview OCmapView赢得';不显示群集/注释?,mkmapview,mapkit,mkannotationview,Mkmapview,Mapkit,Mkannotationview,今天我开始使用OCMapView()并研究了示例项目。。。所以我决定将内容添加到我的项目中。。。一切正常没有红色错误。。。模拟器打开了,什么也没发生,只有一条警告消息显示“你想使用当前位置吗?”然后黑屏显示,这样它就不会真正加载应用程序了。。。我花了几个小时试图解决这个问题。。。所以也许你知道问题在哪里 @implementation AirportsViewController - (void)viewDidLoad { [OCMapView class]; mapView.del
@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;
}
}
@implementation AirportsViewController
-(无效)viewDidLoad{
[OCMapView类];
mapView.delegate=self;
NSArray*机场=[机场所有机场];
[地图视图添加注释:机场];
[mapView setVisibleMapRect:MKMapRectWorld];
}
-(MKAnnotationView*)地图视图:(MKMapView*)用于注释的aMapView视图:(id)注释{MKAnnotationView*注释视图;
静态NSString*reuseIdentifier=@“airportAnnotation”;
if([annotation isKindOfClass:[OCAnnotation class]]){
OCAnnotation*clusterAnnotation=(OCAnnotation*)注释;
annotationView=(MKAnnotationView*)[aMapView出列可重用AnnotationViewWithIdentifier:@“ClusterView”];
如果(!annotationView){
annotationView=[[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:@“ClusterView”];
annotationView.canShowCallout=是;
annotationView.centerOffset=CGPointMake(0,-20);
}
clusterAnnotation.title=@“集群”;
clusterAnnotation.subtitle=[NSString stringWithFormat:@“包含注释:%d”,[clusterAnnotation.annotationsInCluster count]];
//树立形象
annotationView.image=[UIImage ImageName:@“regular.png”];
clusterAnnotation.title=clusterAnnotation.groupTag;
}
else if([annotation isKindOfClass:[Airport class]])){
MKAnnotationView*annotationView=[mapView dequeueReusableAnnotationViewWithIdentifier:reuseIdentifier];
如果(!annotationView){
annotationView=[[MKAnnotationView alloc]initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]autorelease];
annotationView.canShowCallout=是;
}
annotationView.image=((Airport*)注释).icon;
返回注释视图;
}
}
如果有不清楚的地方或我忘记了一些要发布的代码,请提问。您发现了问题吗?