views:

929

answers:

1

I am annotating my map and setting an image just fine, but when I tap the annotation on the MapView, the image goes from my custom image back to the red pin. Why is this?

- (MKAnnotationView *)mapView:(MKMapView *)newMapView viewForAnnotation:(id )newAnnotation {
    MKPinAnnotationView *a = [ [ MKPinAnnotationView alloc ] initWithAnnotation:newAnnotation reuseIdentifier:@"currentloc"];
    if ( a == nil )
     a = [ [ MKAnnotationView alloc ] initWithAnnotation:newAnnotation reuseIdentifier: @"currentloc" ];
    a.image = [ UIImage imageNamed:@"anno.png" ];
    a.canShowCallout = YES;
    a.rightCalloutAccessoryView = [ UIButton buttonWithType:UIButtonTypeDetailDisclosure ];
    UIImageView *imgView = [ [ UIImageView alloc ] initWithImage:[ UIImage imageNamed:@"bus_stop_30x30.png" ] ];
    a.leftCalloutAccessoryView = imgView;
    return a;
}

My code looks identical to some sample code that does not produce this problem.

+2  A: 
dc
thanks for this solution..saved my time...
Sijo