I\'m trying to add MKAnnotationView to MKMapView but I can\'t do it… Can anyone help me?
Here is my code:
override func vie
1- your map view should delegate itself to your view controller 2- you should implement
func mapView(aMapView: MKMapView!, viewForAnnotation annotation: CustomMapPinAnnotation!) -> MKAnnotationView!
this function is called from every annotation added to your Map
3- subclass your annotations to identify them in the viewForAnnotation method
4- in viewForAnnotation, add
if annotation.isKindOfClass(CustomMapPinAnnotation)
{
// change the image here
var pinView = aMapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? YourSubclassedAnnotation
pinView!.image = UIImage(contentsOfFile: "xyz")
}