在MapView中单击AnyWherher时隐藏自定义宣传视图



如何隐藏在MapView中单击AnyWherWher

的自定义宣传视图

我已经使用了TouchSbegan方法,但是当单击PIN区域时它无法正常工作。

无需使用touchesbegan方法,mapView已经具有didDeSelect方法来隐藏注释视图。

func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView) {
    if view.isKind(of: AnnotationView.self)
    {
        for subview in view.subviews
        {
            subview.removeFromSuperview()
        }
    }
}

最新更新