When the view property of a UIViewController is accessed, it first checks to see if it's got an existing view, and returns that. If not, it loads its nib or calls -loadView.
When a controller receives a -didReceiveMemoryWarning message, the default behavior is to remove that cached view (assuming it's not in use at the time).
If I override -didReceiveMemoryWarning, how can I determine whether the view has been cleared? My understanding is that the default implementation checks to see if self.view.superview == nil. If so, it clears the cached view. Of course, it first checks to see if there is a cached view, and if not, it does nothing. However, I, as a subclass, can't call self.view.superview, for if there isn't a view, it'll generate one.
So, how do I figure out if _view exists? (I can't just look at _view; I get linking errors when building for the device).
Since iPhone OS 3.0, you can use the isViewLoaded
method to see if a view is loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With