The leftCalloutAccessoryView property is a property of the MKAnnotationView class (not in the MKAnnotation protocol).
In the delegate method of viewForAnnotation MKMapView, you provide MKAnnotationView for your annotations. In this method, check if the annotation type is your custom annotation type using isKindOfClass, and set the view properties as needed.
NeighborMapAnnotation imageView UIImageView .
viewForAnnotation view leftCalloutAccessoryView imageView.
Edit:
...
:
@interface NeighborMapAnnotation : NSObject <MKAnnotation> {
...
UIImage *image;
}
...
@property (nonatomic, retain) UIImage *image;
@end
, , :
NeighborMapAnnotation *neighbor = [[NeighborMapAnnotation alloc] initWithCoordinate:aCoordinate];
neighbor.image = [UIImage imageNamed:@"someimage.png"];
...
viewForAnnotation (, ):
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation
{
if ([annotation isKindOfClass:[NeighborMapAnnotation class]])
{
static NSString *AnnotationIdentifier = @"AnnotationIdentifier";
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:AnnotationIdentifier];
if (!pinView)
{
pinView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier] autorelease];
pinView.canShowCallout = YES;
pinView.animatesDrop = YES;
}
else
{
pinView.annotation = annotation;
}
UIImageView *leftCalloutView = [[UIImageView alloc]
initWithImage:((NeighborMapAnnotation *)annotation).image];
pinView.leftCalloutAccessoryView = leftCalloutView;
[leftCalloutView release];
return pinView;
}
return nil;
}