2013-06-20 33 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; 
}