0

I am trying to add custom images to my mapView but am not having any luck so far. I keep getting a SIGABRT error when the map is loaded. here is my code:

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {

    if annotation.isKindOfClass(NiteOwlAnnotations) {

        let reuseId = "test"

        var annoView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId)
        if annoView == nil {
            annoView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
            annoView?.image = UIImage(named: "bar-map-icon")
            annoView?.canShowCallout = true
        } else {

            annoView?.annotation = annotation
        }

        return annoView

        /*  let annoView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: "Default")
        // change color of pins.
        annoView.pinTintColor = UIColor.blackColor()
        annoView.animatesDrop = false
        annoView.image = UIImage(named: "bar-map-icon")
        annoView.backgroundColor = UIColor.clearColor()
        annoView.canShowCallout = true
        return annoView
     */
    } else if annotation.isKindOfClass(MKUserLocation) {

        return nil
    }

    return nil

}// end func

//--------------------------------------------------------------

func createAnnotationForLocation(location: CLLocation) {

    let niteOwl = NiteOwlAnnotations(coordinate: location.coordinate)

    map.addAnnotation(niteOwl)

}

I have looked for more information on this and still no luck yet:

Change pin image on MKMapView in Swift

Community
  • 1
  • 1
Jay
  • 103
  • 2
  • 7
  • What exact line error happens on? – Ryan May 06 '16 at 21:06
  • @trick14, the error happens in the appDelegate.swift file, on line: class: AppDelegate: UIResponder, UIApplicationDelegate { , and I'm pretty sure the error is caused by return annoView after the else statement where the custom image is set. – Jay May 07 '16 at 15:07

0 Answers0