隐藏地图注释而不删除它们 [英] Hiding map annotations without deleting them
本文介绍了隐藏地图注释而不删除它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用 MKMapView 我加载了一堆注释,我希望能够过滤显示分段控件的注释.
Using a MKMapView I have a pile of annoatations loaded onto it and I want to be able to filter the annotations displayed with a segmented control.
我正在使用带有类型变量的自定义注释,因此我可以将它们彼此区分开来,但我无法找到一种随意隐藏和显示注释视图子集的方法.
I'm using custom annotations with a type variable so I can tell them apart from one another but I haven't been able to find a way to hide and display a subset of annotation views at will.
推荐答案
当然,试试这个:
Objective-C 解决方案:
[[yourMapView viewForAnnotation:yourAnnotation] setHidden:YES]
Swift 4 解决方案:
yourMapView.view(for: yourAnnotation)?.isHidden = true
这将返回与指定注释对象关联的视图,然后您可以将视图设置为隐藏.这是 文档.
This will return you the view associated with the specified annotation object, then you can set the view to hidden. Here is the documentation.
这篇关于隐藏地图注释而不删除它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文