我想为Google地图标记创建一个信息窗口,以便在我的iOS应用程序的信息窗口中提供按钮点击事件。有没有办法做到这一点?
答案 0 :(得分:0)
希望这可以帮到你
extension ViewController: MKMapViewDelegate {
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {
if annotation is MKUserLocation {
return nil
}
let identifier = "MyCustomAnnotation"
var annotationView = mapView.dequeueReusableAnnotationViewWithIdentifier(identifier)
if annotationView == nil {
annotationView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: identifier)
annotationView?.canShowCallout = true
} else {
annotationView!.annotation = annotation
}
let myButton = UIButton()
annotationView?.leftCalloutAccessoryView = myButton
return annotationView
}
}