ios - Swift mapkit如何隐藏用户的定位销
问题描述
我找不到任何关于此的文档,所以也许我无论如何都不可能问。我需要显示用户位置的蓝点。我的地图视图充满了图钉,有时我的用户正在单击用户位置的蓝色圆圈,这会打开一个小的用户图片图钉。我怎样才能删除它?如果后面有东西,那就很烦人了。
到目前为止,我必须确定何时打开注释视图:
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if(view.annotation?.isKind(of: MKUserLocation.self) != true){
print("test");
}
}
有没有办法取消它的显示?
解决方案
您拥有 99% 的解决方案 - 您已确定何时选择了用户位置注释。完成任务所需要做的就是取消选择它;
func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) {
if view.annotation is MKUserLocation {
mapView.deselectAnnotation(view.annotation, animated: false)
return
}
// Handle selection of other annotations if required...
}
推荐阅读
- java - 为什么 Hibernate 在 Spring 事务中说“无会话”?
- excel - 当成员是 Cubset 函数时,Cubevalue 返回空白(零长度字符串)
- javascript - 将代码移动到导出的函数会导致 TypeError:将循环结构转换为 JSON
- python - 使用 PyOpenGL 和 PyQt5 制作 Sphere 的问题
- dotnetnuke - DotNetNuke 9 中最佳实践 MVC 模块示例
- javascript - 如何撤消“this.onclick=null”?如何将javascript onclick功能恢复到div?
- java - Android Searchview在使用ListView点击项目时过滤错误
- amazon-web-services - 传输 Amazon EC2 实例时主机名和 IP 地址发生变化
- c++ - constexpr:gcc 比 clang 更努力地评估 constexpr
- ffmpeg - ffmpeg 提取帧并根据 exif 或 txt 中每个提取帧的创建时间获取时间戳