我創建了一個自定義類的MKAnnotation定製MKAnnotation類改變leftCalloutAnnotationView
@interface NeighborMapAnnotation : NSObject <MKAnnotation> {
CLLocationCoordinate2D coordinate;
NSString * title;
NSString * subtitle;
UIImageView * lcav;
}
@property (nonatomic, readonly) CLLocationCoordinate2D coordinate;
@property (nonatomic, retain) NSString * title;
@property (nonatomic, retain) NSString * subtitle;
@property (nonatomic, retain) UIImageView * lcav;
@end
NeighborMapAnnotation *neighbor = [[NeighborMapAnnotation alloc] initWithCoordinate:aCoordinate];
//imgView is some UIImageView that I already have
neighbor.leftCalloutAccessoryView = imgView;
- (MKAnnotationView *) mapView:(MKMapView *) mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
MKPinAnnotationView * annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"custom view"] autorelease];
annView.animatesDrop = YES;
annView.canShowCallout = YES;
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annView.rightCalloutAccessoryView = rightButton;
annView.leftCalloutAccessoryView = [annotation lcav];//is this right?
return annView;
}
我希望能夠改變註釋的leftCalloutAccessoryView到的圖像。我應該在自定義MKAnnotation類中更改哪些代碼?
根據以下建議編輯上面的代碼 – aherlambang 2011-01-30 19:19:07