【问题标题】:Button click event inside a map marker info window地图标记信息窗口内的按钮单击事件
【发布时间】:2016-08-03 07:56:06
【问题描述】:

我想为 Google 地图标记创建一个信息窗口,以便在我的 iOS 应用程序的信息窗口内提供一个按钮单击事件。有没有办法做到这一点?

【问题讨论】:

标签: swift google-maps


【解决方案1】:

希望对你有帮助

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
    }

}

【讨论】:

  • 谢谢。但我没有使用地图套件。
  • 抱歉,我没看到:\
猜你喜欢
  • 2020-11-30
  • 2017-11-15
  • 2016-08-26
  • 2014-09-26
  • 1970-01-01
  • 2013-10-06
  • 1970-01-01
  • 1970-01-01
  • 2018-03-26
相关资源
最近更新 更多