I added the ability to capture a single tap on the map, and a selection of detail annotations. When I select a specific annotation, the selection of the selection does not work, I can only click on the detail icon.
let singleTapGesture = UITapGestureRecognizer(target: self, action: #selector(singleTap))
mapView.addGestureRecognizer(singleTapGesture)
@objc func singleTap(sender: UIGestureRecognizer){
print("single tap detect !")
}
func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "Annotation")
annotationView = MapPinView(annotation: annotation, reuseIdentifier: "Annotation")
let rightButton = UIButton(type: .detailDisclosure)
rightButton.addTarget(self, action: #selector(didClickDetailDisclosure(button:)), for: .touchUpInside)
annotationView!.rightCalloutAccessoryView = rightButton
return annotationView
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…