Posted By

espinallab on 04/30/10


Tagged

MKMapView MKAnnotationView


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

umang_nine
bucko
Tintenklecks


Adding a custom Pin Annotation MAPKit


 / Published in: Objective C
 

URL: http://stackoverflow.com/questions/1805897/iphone-annotation-image-disappears-on-touch

Answering my own question here, just in case others have the same issue. Notice that I am using "MKPinAnnotationView" - it should be changed to "MKAnnotationView" and everything works.

  1. - (MKAnnotationView *)mapView:(MKMapView *)newMapView viewForAnnotation:(id )newAnnotation {
  2. MKAnnotationView *a = [ [ MKAnnotationView alloc ] initWithAnnotation:newAnnotation reuseIdentifier:@"currentloc"];
  3. if ( a == nil )
  4. a = [ [ MKAnnotationView alloc ] initWithAnnotation:newAnnotation reuseIdentifier: @"currentloc" ];
  5. a.image = [ UIImage imageNamed:@"anno.png" ];
  6. a.canShowCallout = YES;
  7. a.rightCalloutAccessoryView = [ UIButton buttonWithType:UIButtonTypeDetailDisclosure ];
  8. UIImageView *imgView = [ [ UIImageView alloc ] initWithImage:[ UIImage imageNamed:@"bus_stop_30x30.png" ] ];
  9. a.leftCalloutAccessoryView = imgView;
  10. return a;
  11. }

Report this snippet  

You need to login to post a comment.