title: estimatedHeightForRowAtIndexPath can in fact change the final "correct" height of a row?
body: <p>I've just discovered an astounding problem or counter-intuituve behaviour when using estimatedHeightForRowAtIndexPath</p>
  
  <p>(1) My table has wildly varying row heights. The final results can range from 111 to about 400.</p>
  
  <p>(2) I absolutely perfectly calculate each row height. I have these on hand in an array, that is to say cached.</p>
  
  <p>{Note that this is exactly what, apparently, Apple engineers now recommend...example, point 5 .. <a href="https://stackoverflow.com/questions/18746929/using-auto-layout-in-uitableview-for-dynamic-cell-layouts-heights">Using Auto Layout in UITableView for dynamic cell layouts &amp; variable row heights</a>}</p>
  
  <p>(3) When heightForRowAtIndexPath asks for a height, I do give it absolutely the correct height.</p>
  
  <p>(4) WHen I build the cell, indeed, I build it to exactly the correct height (as in (2) and (3)).</p>
  
  <p>{Note - of course it's iOS that finally sizes the height of a cell, not "me".}</p>
  
  <p><strong>THIS ALL WORKS PERFECTLY.</strong></p>
  
  <p>ie, each cell is built by iOS at exactly the height given in heightForRowAtIndexPath.</p>
  
  <p>Now, I add the code ... </p>
  
  <pre><code>-(CGFloat)tableView:(UITableView *)tableView
      estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
      return 120;
  }
  </code></pre>
  
  <p><strong>IN FACT, THE TABLE NO LONGER WORKS .................. THE ROW HEIGHTS BECOME RANDOM!!!</strong></p>
  
  <p><strong>HAS ANYONE SEEN THIS INCREDIBLE BEHAVIOUR?</strong></p>
  
  <p>I did various tests to try to determine the relationship of what  the hell estimatedHeightForRowAtIndexPath does.  At first, I thought it might provide a lower bound on the height. So, 150 .. even my smaller cells would incorrectly be 150 height.  But that is not the case.</p>
  
  <p>I think it MIGHT be doing something like this:  say your estimatedHeightForRowAtIndexPath value is 150.  It is sometimes using 150 for rows that (in fact() prove to be that size or less, but sometimes it goes for the real size from heightForRowAtIndexPath.</p>
  
  <p>On the other hand, if you put in a value for estimatedHeightForRowAtIndexPath that is smaller than will ever actually exist (say 100 in my example) it pretty much "utterly doesn't work" you just get what can only seem to be random heights on the cells.</p>
  
  <p>very high cells seem to work correctly, perhaps something like "if the height from heightForRowAtIndexPath is double the estimated, then it does use the real height"</p>
  
  <p>To be clear, it seems that it never makes a cell too small, but it often makes them too big.</p>
  
  <p>To be clear, I am <strong>not</strong> using autolayout, it's the type of cell you just have to build.  (I'm afraid I have no idea how this goes with autolayout.)  This is Xcode5/iOS7+ only.</p>