title: Prevent views from popping from the top left during animations on iOS
body: <p>Sometimes when table view cells appear in animations, e,g, <code>-[UIView viewWillAppear:animated]</code> with <code>-[UITableView reloadData]</code>, the contents inside them pop from top left corner (0, 0) to the final frames. This problem also happens in other view  animations. Back in the very old days, this problem did not exist. In one iOS update, the problem appeared but the initial positions were random, usually outside the screen. In another iOS update, the problem became deterministic with the initial position being (0,0).</p>
  
  <p>I have tried <code>[tableView layoutIfNeeded]</code>, <code>[tableView.layer displayIfNeeded]</code> after <code>[tableView reloadData]</code> and those on cells in <code>cellForRowAtIndexPath</code>. What were I missing?</p>
  
  <p>I uploaded a sample project <a href="https://github.com/keithyipkw/ios-animation-bug" rel="nofollow noreferrer">https://github.com/keithyipkw/ios-animation-bug</a>.
  To reliably reproduce the problem, set a breakpoint at viewWillAppear, before reloadData. Pull down the screen to show the today center. Run after the today center fully visible.</p>
  
  <p><a href="https://i.stack.imgur.com/7gRF4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7gRF4.png" alt="screenshots"></a></p>