【发布时间】:2016-11-24 08:34:47
【问题描述】:
我在故事板上有一个 MapView 并选中了 User Location 选项。我还编写了一些代码来在地图上绘制另一个注释。此注释 (tappedCoordinates) 的坐标源自已注册的手势。
//add new annotation
let annotation = MKPointAnnotation()
annotation.coordinate = tappedCoordinates
mapView.addAnnotation(annotation)
//add circle radius
let circle = MKCircle(center: tappedCoordinates, radius: 20)
mapView.setRegion(MKCoordinateRegion(center: tappedCoordinates, span: MKCoordinateSpan(latitudeDelta: 0.002, longitudeDelta: 0.002)), animated: true)
mapView.add(circle)
此代码允许用户在地图上绘制注释(图钉)。它工作正常,除非用户尝试在其当前位置绘制注释。相反,MapView 认为您选择了当前位置注释,并显示“当前位置”,而不是允许用户绘制自定义注释。
如何阻止用户位置注释被点击,并允许我的自定义注释被放置在同一区域?我不想删除当前位置注释。
【问题讨论】:
-
您可能将 userInteractionEnabled 设置为 false 以防止触摸它
标签: ios objective-c swift annotations