Compatibility with ios6.0 memory warning handling viewdidunload shielding

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.