Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You are re-using the same instance of a table view controller for the "Master" table, but you are sending it messages in what appears to be the wrong order. </p> <p>You push the controller like this:</p> <pre><code>if (!self.masterViewController) { self.masterViewController = [[MasterViewController alloc] init]; } self.masterViewController.objects = self.masterObjects[indexPath.row]; [self.masterViewController.tableView reloadData]; [self.navigationController pushViewController:self.masterViewController animated:YES]; </code></pre> <p>If you simply swap around the reloadData and push lines, then your problem disappears.</p> <p>I'm not entirely sure what is happening here, but I <em>think</em> the problem is that, once the master controller is popped, it doesn't have any frame of reference (pun intended!) to calculate the appropriate content size when you reload it, so it probably isn't caching the content size for this new height. </p> <p>Then, when the view is pushed, the scroll view suddenly has a context again, it knows it has recalculated and so uses the cached content size. That is the impression I get (as you did) from the stack trace, anyway. The first table you choose is always fine since there isn't an old size available. If you'd made this with storyboards you would be instantiating a new Master controller each time and you'd never have noticed a problem. </p> <p>As for why autolayout makes any difference, well, again I'm only guessing and hand-waving here, but under autolayout everything happens a lot later on in the view controller lifecycle than it does under explicit layout. If you have autolayout all the way down, then in a view with no superview (and therefore no constraints on its size) autolayout is not able to work out what size things should be. It's probably a bug, but the workaround is trivial enough and as I say, typically when pushing new view controllers onto a navigation stack you'd initialise new ones, and they'd go away when they were popped, so you'd never see this. </p>
 

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