Compatibility with ios6.0 memory warning handling viewdidunload shielding
Compatibility handling of memory Warnings:
Versions earlier than ios6.0 receive the memory warning:
Calling didreceivememorywarning to call didreceivememorywarning of super will release the Controller view. Therefore, we cannot release the Controller view again.
Solution:
-(Void) didreceivememorywarning
{
[Super didreceivememorywarning];
// No processing is performed before ios6.0
}
-(Void) viewdidunload
{
// Release any retained subviews of the main view. does not contain self. View
[Super viewdidunload];
}
Ios6.0, memory warning:
Call didreceivememorywarning to call didreceivememorywarning of super. The call only releases the resouse of the controller and does not release the view.
Solution:
-(Void) didreceivememorywarning
{
[Super didreceivememorywarning];
// Add code to clean up any of your own resources that are no longer necessary.
// The ios6.0 macro switch must be added for compatibility processing to ensure that it is used under 6.0. The following code is blocked before 6.0. Otherwise, viewdidload will be automatically loaded when self. View is used below.
If ([self. View window] = nil) // whether the view is in use
{
// Add code to preserve data stored in the views that might be
// Needed later.
// Add code to clean up other strong references to the view in
// The View hierarchy.
Self. view = nil; // The object is reloaded upon re-entry
}
}
For more information about official documents, see
Https://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ViewLoadingandUnloading/ViewLoadingandUnloading.html
Re: http://www.cocoachina.com/bbs/simple? T125949.html