MapKit中的引脚错误呈现(颜色和注释)

时间:2015-05-18 11:47:20

标签: ios objective-c mkmapview mkannotationview

我正在使用MapKit开发一个应用程序,我在呈现多个点/引脚时遇到了麻烦 ("见附图")。

See self-explanatory Figure here - Progress screens

启动App时,引脚呈红色(但代码中的代码设置为绿色 - "请参阅代码")。

-(void)desenhaMapa
{
for (int i=0; i<[_igrejas count]; i++) {

    Igreja *igrejaAtual=[_igrejas objectAtIndex:i];


    if (([[igrejaAtual longitude]length]!=0) && ([[igrejaAtual latitude]length]!=0) && ([[igrejaAtual coordenada]length]!=0) ){

    MKCoordinateRegion regiao;

    CLLocationCoordinate2D coordenada;
    [self.lblMapa setMapType:MKMapTypeHybrid];

    coordenada.longitude = [[igrejaAtual longitude]doubleValue];
    coordenada.latitude = [[igrejaAtual latitude]doubleValue];
    regiao.center = coordenada;

    regiao.span.latitudeDelta = 3.0;
    regiao.span.longitudeDelta = 3.0;


    [[self lblMapa]setRegion:regiao animated:YES];

    PontoMapa *pontoMapa = [[PontoMapa alloc]initWithCordinate:regiao.center Title:[igrejaAtual nome] Subtitle:[igrejaAtual endereco] id:[igrejaAtual id_iasd]];

    [[self lblMapa]addAnnotation:pontoMapa];

    }

}

self.lblMapa.delegate = self;

}

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{

  static NSString *reuseId = @"pinView";

MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:reuseId];

if (!pinView)
{
    pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:reuseId];

    pinView.pinColor = MKPinAnnotationColorGreen;

    pinView.canShowCallout = YES;
    UIButton *btPin = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

    pinView.rightCalloutAccessoryView = btPin;

    return pinView;
}
else
{
    pinView.annotation = annotation;

    return pinView;
}


 return nil;
}



- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
PontoMapa *ponto = (PontoMapa *)[view annotation];

DetalhesViewController *diVC = [[self storyboard]instantiateViewControllerWithIdentifier:@"detalheIgreja"];

NSMutableArray *igrejaAtual = [DBServiceViewController getIgrejasById:ponto.id_igreja cache:cache];
if ([igrejaAtual count]>0)
    [diVC setDetalhesIgreja:igrejaAtual[0]];
[[self navigationController]pushViewController:diVC animated:YES];
}

在地图上执行放大或隐藏所有引脚后,引脚变为绿色并显示按钮rightCalloutAccessoryView
我试图通过论坛中的几个相关帖子解决问题,但无法解决! 请帮帮我! 谢谢!

0 个答案:

没有答案