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.
Sure, try this:
Objective-C solution:
[[yourMapView viewForAnnotation:yourAnnotation] setHidden:YES]
Swift 4 solution:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With