Adding a custom Pin Annotation MAPKit


/ Published in: Objective C
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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. }

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.