2013-06-20 7 views
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]; 

} 

ответ

1

Попробуйте установить leftCalloutAccessoryView в методе делегата от вида карты viewForAnnotation, например:

- (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; 
}