3

I have an app which has a lot of annotations and I want to have their call outs open at the beginning(and if its possible never disappear). What I accomplished since now is to have only one always appeared and when I tap the map it disappears with this line:

 mapView.selectAnnotation(mapView.annotations[1], animated: true)

Thanks in advance.

mike vorisis
  • 2,786
  • 6
  • 40
  • 74

1 Answers1

3

I just did some research and I found that it's not possible from public API and MKMapView mechanisms.

The code below just select an annotation and in the same time deselect the previous one.

for annotation in mapView.annotations {
     mapView.selectAnnotation(annotation, animated: true)
}

So to provide the behavior you've described you have to implement some custom mechanism.

Also, you might look to this answer. It would be very helpful.

Community
  • 1
  • 1
kamwysoc
  • 6,709
  • 2
  • 34
  • 48
  • Thanks for your answer but now I don't have any annotations call out (where should I put this loop, now I put it inside viewdidload where all my code for map is) – mike vorisis Nov 20 '16 at 20:31
  • Yes I was running a test program and I forgot the second title now I put it the second title only showed the last annotation call out – mike vorisis Nov 20 '16 at 20:38
  • it also showed me only the last annotation. so I will subtract a mark for now. – nyxee Jun 07 '17 at 13:30