从地图注释标题中删除信息按钮选项

时间:2015-02-19 10:52:46

标签: ios iphone mkmapview mkmapitem

PREAMBLE

我使用MKMapView和MapAnnotation实现了地图注释。点按时会出现标题视图,如下图所示。

map annotation title

我使用以下LOC来实现所述地图注释:

// VENUE 1 PIN.

CLLocationCoordinate2D venue1Location = CLLocationCoordinate2DMake(-27.5, 153.5);

MapAnnotation *venue1Pin = [[MapAnnotation alloc] initWithTitle:@"1 ONE ST" Location:venue1Location];

查看注释代理方法:

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MapAnnotation class]])
{
    MapAnnotation *venueLocationAnnotation = (MapAnnotation *)annotation;

    MKAnnotationView *venueLocationAnnotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"customAnnotation"];

    venueLocationAnnotationView.rightCalloutAccessoryView.hidden = YES;

    if (venueLocationAnnotationView == nil)

        venueLocationAnnotationView = venueLocationAnnotation.annotationView;

    else

        venueLocationAnnotationView.annotation = annotation;


        return venueLocationAnnotationView;

}
else
{
    return nil;
}

}

问题

如何从上述地图注释标题视图中删除信息按钮?

3 个答案:

答案 0 :(得分:2)

您可以使用以下声明:

您必须为此实现以下委托方法:

 - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{
         ...
         venue1Pin.rightCalloutAccessoryView = nil;
         ...
    }

答案 1 :(得分:1)

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];
annotationView.canShowCallout = YES;

annotationView.rightCalloutAccessoryView.hidden=YES;

return annotationView;
}

答案 2 :(得分:1)

-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[MKPointAnnotation class]])
 {
  MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapView   dequeueReusableAnnotationViewWithIdentifier:@"yourPinIdentifier"];
     if (!pinView)
     {
       pinView.rightCalloutAccessoryView.hidden=YES;
       pinView.animatesDrop = YES;
       pinView.canShowCallout = YES;
     }

    return pinView;
 }
}