I am putting annotation
on a map and after clicking the pin, there should be a detail disclosure info button
on the right side, so I can add more code after tapping the button. But when I run the project, clicking on the pin, there is no info button
shows up. Can anyone provide code to add disclosure info button
?
I am expecting an info button on the right:
My Code:
extension ViewController: MKMapView{
func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {
}
Create a MKAnnotationView
and add a button to it. So:
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation { return nil }
if let annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "") {
annotationView.annotation = annotation
return annotationView
} else {
let annotationView = MKPinAnnotationView(annotation:annotation, reuseIdentifier:"")
annotationView.isEnabled = true
annotationView.canShowCallout = true
let btn = UIButton(type: .detailDisclosure)
annotationView.rightCalloutAccessoryView = btn
return annotationView
}
}