隐藏地图注释而不删除它们
使用 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然,试试这个:
Objective-C 解决方案:
Swift 4 解决方案:
这将返回与指定注释对象关联的视图,然后您可以将视图设置为隐藏。这是 文档。
Sure, try this:
Objective-C solution:
Swift 4 solution:
This will return you the view associated with the specified annotation object, then you can set the view to hidden. Here is the documentation.
如果您想隐藏 MKAnnotationView(气泡),您可以创建一个自定义视图:
if you want to hide the MKAnnotationView (bubble) you can create a custom one: