Pages

Tuesday, April 2, 2013

[Bug in sample Code] On iOS 6 and Later, a View Controller Unloads Its Own Views When Desired

Documet Link

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPho neOS/ViewLoadingandUnloading/ViewLoadingandUnloading.html#//apple_ref/doc/uid/TP 40007457-CH10-SW15

 

On iOS 6 and Later, a View Controller Unloads Its Own Views When Desired

Listing 4-3  Releasing the views of a view controller not visible on screen

- (void)didReceiveMemoryWarning

{

    [super didReceiveMemoryWarning];

    // Add code to clean up any of your own resources that are no longer necessary.

    if ([self.view window] == nil)

    {

        // 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 Condition should be   [self isViewLoaded] && [self.view window] == nil


View the original article here

0 comments:

Post a Comment