Reputation: 6971
This issue never happened to me. I have an UIViewController inside an UINavigationController. When a memory warning is received (nevermind the level), the viewDidUnload
method of the visible controller is called, so the view is unloaded and I get an awesome black screen (with a navigation bar at the top).
I'm testing with an iPad 1 on iOS 4.3.3.
Any suggestions?
Upvotes: 6
Views: 802
Reputation: 9942
From what I understand, the viewDidUnload
method is called by didRecieveMemoryWarning
function in the UIViewController
(the super class). Basically iOS gives you couple of warnings and expect to see your memory usage go down. If you continue to ignore these, OS will kill your app.
Sometimes, though, it is critical to keep some views up and running so the way I get around this is to simply override the didRecieveMemoryWarning
method and inside it, don't do anything.
Or better yet, check if self
is the current view in the self.navigationController.visibleViewController
, and if so, don't pass the memory warning call down to [super didRecieveMemoryWarning]
.
If you are holding image caches or something, just empty those instead.
HTH
Upvotes: 1
Reputation: 790
You receive viewDidUnload in low memory situation on controllers, where iOS has determined that the views are not longer needed. Remember that Apple made some improvements on the implementations on later versions of iOS, so it might be worse seeing what happens under 5.x. Second you should review your view controller hierarchy.
Upvotes: 0
Reputation: 994
According to Apple
memory management guidelines when a viewcontroller
recieves memory warnings in critical situations it directly calls viewDidUnload
so that memory can be managed by releasing the view.
Its actually ios providing chance to purge your temporary data which wil be useful while recreating the view. Since your UIViewCotroller
is the root viewcontroller
of the navigationcontroller
you see oly navigationbar the view gets unloaded.
Upvotes: 0