3

I have 10 custom annotations on my map but sometimes the callout pops out behind the pins.. any idea to resolve this?

I have checked out this link Z-ordering of MKAnnotationViews

but since my callouts are not popping up by tap but they are popping up by click on button so this answer is worthless to me.

Any kind of help will be really appreciated.

Community
  • 1
  • 1
Suresh Varma
  • 9,750
  • 1
  • 60
  • 91
  • if you are not clear with the question.. feel free to comment. – Suresh Varma Jul 20 '11 at 11:59
  • i don't know if it works, but just to know, have you tried to call bringSubviewToFront on the view of the selected annotation? – Mat Jul 20 '11 at 12:08
  • in mapview didnt find any such method.. it crashes if i pass annotation as subview :( – Suresh Varma Jul 20 '11 at 12:16
  • I have tried to bringSubviewToFront with annotationview...[self.mapview bringSubviewToFron: annotationView] but still its the same :( – Suresh Varma Jul 20 '11 at 12:24
  • Is the callout view custom or the annotation view? Have you implemented viewForAnnotation and are you using MKPinAnnotationView? –  Jul 20 '11 at 12:25
  • @suresh varma bringSubViewTo front is a method of UIView, so you should call like [mapView bringSubViewToFront:annotation.view];...Ok i see now your last comment :) – Mat Jul 20 '11 at 12:26
  • @mat dats what i have written in the previous comment.. – Suresh Varma Jul 21 '11 at 04:53
  • @anna Kerenina.. I am not using MKPinAnnotationView. The callout view is annotattionview nut its custom. I have used all the functions required in MKMapvview. including viewForAnnotation – Suresh Varma Jul 21 '11 at 04:54
  • Just checking. Are you using [mapView selectAnnotation:animated:] to pop up callouts??? – Bushra Shahid Jul 21 '11 at 09:05
  • no.. it was not working for me.... so i used -(void)mapView:(MKMapView *)sender didSelectAnnotationView:(MKAnnotationView *)aView – Suresh Varma Jul 21 '11 at 09:45
  • Can you post the code in viewForAnnotation and didSelectAnnotationView? –  Jul 21 '11 at 18:13
  • mapView:didSelectAnnotationView: is where you would create a "custom callout", but not to trigger the callout. Used in that way could cause your Z-Order problem because a view would get drawn but none of the setup would have been completed by mapView. I'd investigate why selectAnnotation:animated: isn't working. – Barney Mattox Jul 30 '11 at 09:49

1 Answers1

1

The reason behind this is because some where in your code you are calling bringSubviewToFront on the annotationView.

RocketMan
  • 4,289
  • 2
  • 26
  • 19
  • Yes i an adding a transparent view on the top of the map which lightens the map when my custom annotations are there on map. so to make my annotations clickable I have to call them by bringsubviewtofront. but i have done the same for callout also but it dont comes out :( – Suresh Varma Aug 04 '11 at 06:25
  • 1
    Suresh, try calling the bringSubviewToFron on the map superView instead of the mapview. self.mapview.superView bringSubviewToFront: annotationView – RocketMan Aug 04 '11 at 17:55