开发者

iPhone - Problem with MKMapView instance

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开发者_StackOverflow 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


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.


Because it is using too much memory, so it is being deallocated.
You should keep in a model all info about the view (annotations, map region)
So that in the viewDidLoad you could preset it.


I added the loading of the annotations to -viewDidLoad and think it works now as it should. Thanks for your help!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜