Search code examples
iosxcodemkmapviewmkannotationmkannotationview

Add a picture in a MKAnnotationView inside the title


I was searching for any lib that allows me to do this:

1 http://zsoft.es/imgs/annotations.jpg

And the possibly to add a button in the right part in the title, also if possible adding more images in the subtitle or the button in the subtitle...

Thanks.


Solution

  • From the Apple documentation use leftCalloutAccessoryView:

    In (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation

    You can assign a UIImageView to the leftCalloutAccessoryView:

    myAnnotationView.leftCalloutAccessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"myImage.png"]