didReceiveMemoryWarning called but not viewDidUnload?
I'm running into a situation where didReceiveMemoryWarning is being called but viewDidUnload is not. The docs for didReceiveMemoryWarning say:
The default implementation of this method checks to see if the view controller can safely release its view. This is possible if the view itself does not have a superview and can be reloaded either from a nib file or using a custom loadView method. If the view can be released, this method开发者_运维百科 releases it and calls the viewDidUnload method.
The view controller is not visible at the time but is the parent for a modal that is (usually under a image picker when the memory warning is made). It seems like the view should be able to be released, but maybe I'm missing something.
The reason this matters is that I've been releasing some cached data in didReceiveMemoryWarning on the assumption that viewDidLoad will be called when the view is reloaded. But as viewDidUnload is not being called, neither is viewDidLoad when the view is being shown again...
The controller's view does have a superview, even when it's hosting a modal view controller (after all, that controller's view ends up as a subview of that of the controller presenting it), and so its view isn't getting unloaded. I'd recommend picking up your cached data again in -viewWillAppearAnimated:
.
精彩评论