1

I am having a hard time figuring out how to let users select more than one annotation on a map at a time. My annotationViews do not show callouts, but the annotationView's image does change when selected. Is there an easy way to enable this behavior?

To clarify, I need all of the annotations that are selected to remain in a 'selected' array (not just have a visual indicator that they are selected) that can have actions performed on them as a group (for example, the user could delete all of the selected annotations at once).

Another way of stating it might be that I need to have the annotations actually be recognized as being selected, not just have that appearance.

EmilyP
  • 118
  • 1
  • 12
  • Possible duplicate of [Multiple annotation callouts displaying in MKMapView](http://stackoverflow.com/questions/2417952/multiple-annotation-callouts-displaying-in-mkmapview) – Vlad Z. May 13 '16 at 19:38
  • I have updated my post to try to clarify my problem. – EmilyP May 15 '16 at 19:04
  • I don't understand the problem. You can already do this. You can track all selected annotations in an array or use MKMapView.selectedAnnotations: http://i.imgur.com/PsVV24R.png – Brandon May 15 '16 at 19:08
  • That array will only hold one annotation. As soon as I add an annotation to it, it deselects and removes any currently selected annotations. – EmilyP May 15 '16 at 19:22
  • "To clarify, I need all of the annotations that are selected to remain in a 'selected' array (not just have a visual indicator that they are selected)" So do that: make an array and use it to keep track of them when they are selected. What's the problem? – matt May 15 '16 at 20:48

1 Answers1

4

I discovered that I had been looking at this problem for too long and was making it much harder than it was. Using MapKit, it is not possible to handle multiple selected annotations at one time.

Instead, I had to override the MKMapViewDelegate methods mapView:didSelectAnnotationView: and mapView:didDeselectAnnotationView: and create my own methods to handle saving the selected annotations to an array and removing them as well. Those methods also handled setting the appearance of selected annotations.

EmilyP
  • 118
  • 1
  • 12