我正在寻找向注释引脚的标注气泡添加手势的答案。
我尝试了不同的解决方案,但它们对我不起作用。
这是最新的:
func mapView(mapView: MKMapView, didSelectAnnotationView view: MKAnnotationView{
let rightButton = UIButton(type: UIButtonType.detailDisclosure)
let gesture = UITapGestureRecognizer(target: self, action: #selector(callout(gesture:)))
rightButton.addGestureRecognizer(gesture)
view.rightCalloutAccessoryView = rightButton
}
@objc func callout(gesture: UITapGestureRecognizer){
print("tapped")
}
正确的委托方法
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
///
}
加
self.mapView.delegate = self