Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You could set a breakpoint in <code>viewDidLoad</code> and look at the stack trace to see why it's reloading its view.</p> <p>But I can make an educated guess. When you tell the navigation controller to pop a view controller, it needs to animate that view controller's <code>view</code> off the screen. To do so, it probably asks the disappearing view controller for its <code>view</code>.</p> <p>A <code>UITableViewController</code>'s <code>view</code> is the same as its <code>tableView</code>. When you set <code>tableView</code> to <code>nil</code>, you also set <code>view</code> to <code>nil</code>. So when the navigation controller asks the table view controller for its <code>view</code> (so it can animate the view off the screen), the table view controller notices that its <code>view</code> is nil, so it loads its view. And to load its view, it sends itself <code>loadView</code> and then it sends itself <code>viewDidLoad</code>.</p> <p>I don't know why you would really bother trying to unload the view. If the view controller itself gets deallocated, it will release its view (which will deallocate the view unless you've retained it somewhere else). And if the view controller doesn't get deallocated, isn't that usually because you might want to put its view back on the screen soon?</p> <p>Anyway, if you really want to get rid of a view controller's view, don't set its <code>view</code> to <code>nil</code> while the view might still be in the on-screen view hierarchy. Wait until the view is definitely out of the hierarchy. For example, subclass <code>UITableViewController</code>, and override <code>didMoveToParentViewController:</code> like this:</p> <pre><code>- (void)didMoveToParentViewController:(UIViewController *)parentViewController { [super didMoveToParentViewController:parentViewController]; if (parentViewController == nil) { self.tableView = nil; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload