title: UITableView content size while using auto-layout
body: <p>I want to calculate Content size of my <code>UITableView</code>. I am using autolayout  with height <code>UITableViewAutomaticDimension</code>.</p>
  
  <p>Tried to get <code>[UITableView contentsize]</code> after reloading tableview, in that case height get calculated based on <code>estimatedRowHeight</code>.</p>
  
  <pre><code>self.tableView.estimatedRowHeight = 50;
  self.tableView.rowHeight = UITableViewAutomaticDimension;
  </code></pre>
  
  <p>Delegate - </p>
  
  <pre><code>- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
      return UITableViewAutomaticDimension;
  }
  </code></pre>
  
  <p>Trying to get content size and assign it to height constrain.</p>
  
  <pre><code>[self.tableView reloadData];
  [self.tableView layoutIfNeeded];
  self.tableHeightConstraint.constant = self.tableView.contentSize.height;
  </code></pre>
  
  <p>Any suggestions? Thanks in advance.</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Finally I am solved my problem with some tweak. I changed tableview height to max (In my case 300 is max) before reloading data on table, so tableview has space to resize  all cells.</p>
  
  <pre><code>self.tableHeightConstraint.constant = 300;
  [self.tableView reloadData];
  [self.tableView layoutIfNeeded];
  self.tableHeightConstraint.constant = self.tableView.contentSize.height;
  </code></pre>
  
  <p>Thanks for help.</p>