View Map Abstract Delegates for Quick 3.0

// MARK: - MapView Delegate
override func mapView(_ mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {

    var anView = mapView.dequeueReusableAnnotationView(withIdentifier: annotationReuseId)

    if anView == nil {
        anView = MKAnnotationView(annotation: annotation, reuseIdentifier: annotationReuseId)
    } else {
        anView!.annotation = annotation
    }
    anView!.image = UIImage(named: "Contactus_gatePin")
    anView?.frame = CGRect(x: 0, y: 0, width: 53, height: 53)
    anView!.backgroundColor = UIColor.clear
    anView!.canShowCallout = false
    return anView
}

override func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
    return
}

I get an error for this method in Swift3. It worked in Swift2.2 I could not convert this to Swift 3.0
Please help

+4
source share
2 answers

In Swift 3, the viewForAnnotationmethod MKMapViewDelegatechanges as follows.

optional func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

}

Other methods check Apple Documentation for MKMapViewDelegate.

+3
source

annotation method in swift 3.0

 optional func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {

    }
0
source

Source: https://habr.com/ru/post/1656838/


All Articles