How to use custom icons with mapKit framework?
You can change the annotation image by using following code,
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation
{
if ([[annotation title] isEqualToString:@"Current Location"]) {
return nil;
}
MKAnnotationView *annView = [[MKAnnotationView alloc ] initWithAnnotation:annotation reuseIdentifier:@"currentloc"];
if ([[annotation title] isEqualToString:@"McDonald's"])
annView.image = [ UIImage imageNamed:@"mcdonalds.png" ];
else if ([[annotation title] isEqualToString:@"Apple store"])
annView.image = [ UIImage imageNamed:@"applestore.png" ];
else
annView.image = [ UIImage imageNamed:@"marker.png" ];
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[infoButton addTarget:self action:@selector(showDetailsView)
forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = infoButton;
annView.canShowCallout = YES;
return annView;
}
where "marker.png" is your image file.