You must execute the MapKit delegate method mapView:viewForAnnotation:with a custom view.
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation
{
static NSString *annotationViewReuseIdentifier = @"annotationViewReuseIdentifier";
MKAnnotationView *annotationView = (MKAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationViewReuseIdentifier];
if (annotationView == nil)
{
annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationViewReuseIdentifier] autorelease];
}
annotationView.image = [UIImage imageNamed:@"pin_image.png"];
annotationView.annotation = annotation;
return annotationView;
}
To encapsulate more, you must create a custom annotation view as you did, and serve the delegate method above with your class.
MapAnnotation, . iOS , . , , MKAnnotationView . CustomPinAnnotationView.