ios - 将委托(delegate)添加到 CalloutView

标签 ios swift mapbox

我目前正在使用 MapBox swift 库,并且正在尝试向标注 View 添加委托(delegate)。

我正在尝试这样做:

func mapView(_ mapView: MGLMapView, calloutViewFor annotation: MGLAnnotation) -> MGLCalloutView? {
    let callout = TabletMapSearchCalloutView(representedObject: annotation, mapView: mapView)
    callout.delegate = self
    return callout
}

但似乎有一个内部工作人员在库中运行,该工作人员在此方法之后将委托(delegate)设置为 MGLMapView

所以我的问题是,如何向标注添加委托(delegate)以便我可以访问点击的事件?

最佳答案

看来MGLMapViewDelegate有我正在寻找的方法

func mapView(_ mapView: MGLMapView, tapOnCalloutFor annotation: MGLAnnotation)

关于ios - 将委托(delegate)添加到 CalloutView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48983397/

相关文章:

dictionary - Mapbox fitBounds,函数边界映射但不渲染图 block

ios - iOS 中的段错误

ios - 应用安装失败 : Unknown Error Xcode

javascript - Cordova/Phonegap为不同页面设置不同的设备方向

ios - View Controller 关闭并重新出现以前的 View Controller

ios - 聊天消息未正确加载

ios - 期望返回 swift 的函数中缺少返回

ios - 快速调用方法(方法在下一行之前没有完成)

ios - 使 Mapbox RMAnnotation 以编程方式显示其标注

javascript - MapBox/Open Layers map 渲染图 block 不正确