0

我正在尝试向我的注释区域添加一个通用标注附件,但由于某种原因它没有显示出来。这是代码:

- (void) setupMap:(PFObject*) venue {

...

OTNVenueAnnotation *annotation = [[OTNVenueAnnotation alloc] init];
annotation.coordinate = CLLocationCoordinate2DMake(location.latitude, location.longitude);
annotation.title = [[venue objectForKey:@"name"] uppercaseString];
annotation.venue = venue;


UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"identifier"];
customPinView.leftCalloutAccessoryView = rightButton;
[self.mapView addAnnotation: annotation];

}
4

1 回答 1

1

尝试在地图视图viewForAnnotation的委托方法中设置 leftCalloutAccessoryView ,例如:

- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation 
{
    MKPinAnnotationView *annView= (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:@"identifier"];
    UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    annView.leftCalloutAccessoryView = rightButton;
    annView.canShowCallout = YES;
    return annView;
}
于 2013-06-21T01:26:55.610 回答