views:

31

answers:

1

My root view controller is a map with several annotations. When an annotation is selected and the accessory button is tapped, I display a modal view that looks like so: http://i.imgur.com/hACyH.png

In this modal view, you can get a street view look at the annotations coordinate (I do this using a UIWebview). You can also submit a photo, or do a couple other tasks that appear to be relatively high in memory consumption. Anytime I get "Received memory warning" message in the console while I have the modal view displayed, the parents objects (IE the MapKit object) appear to get released because once I dismiss the modal view, the map is now centered on the center of the earth (somewhere in the south atlantic ocean near africa) and a tableview is empty.

I want to preserve these objects, even if there's a memory warning. What appears to be causing this is that viewDidUnload is being called in the root view controller, and in this method, I'm setting all my variables to nil. What's the proper way to handle this memory situation?

Thanks!

+2  A: 

If you do get didReceiveMemoryWarning, the default implementation will unload its view if it is ok to do so and then call viewDidUnload. I don't know how you have setup your controller, but you might have to store the current coordinate and then when viewDidLoad / Appear gets called, you can then ensure that the map is set to the location you want. Here is the apple docs on the view controller life cycle

Scott Densmore
I'm not using the didUnload method anymore and it's working fine. The only downside is that I'm getting non-stop memory warnings with the UIWebview, but the app seems to run fine now. Now I'm going to discover how to get rid of persistent memory warnings with a UIWebview.
culov