R – iPhone – Problem with MKMapView instance

iphonemkmapviewobjective creference

I've got a problem with a MKMapView, which is placed as a full-sized view in a UITabBarController at first position. Before the view will be shown, I add several annotations to the mapView. Everything just works fine.

When I change the tab (so that the mapView is out of view) and switch back to the tab with the mapView, all annotations are gone and it looks like the mapView is reset to default settings.

After debugging I found out, that when I switch back to the tab with the mapView, the reference to the mapView object points to a completly different address than before. I assume, that the mapView has been deallocated after leaving the tab, but I completely don't know why?

Thanks in advance for your replies!

Greetings,
Sebastian

Best Answer

Where are you putting your map annotations initialization code? In -viewDidUnload, you're probably setting mapView to nil, no? If so, make sure when the view is initialized again in -viewDidLoad, you're (re)adding the annotations.

If you have code, that would also help.

Related Topic