我正在尝试将一个通用标注附件添加到我的注释区域,但由于某种原因它没有出现。 这是代码:
- (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];
}
答案 0 :(得分: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;
}