title: dynamic height of UITableViewCell using UIStackView
body: <p>For much to many hours I have been struggling to get dynamic row height calculation for UITableViewCells running.</p>
  
  <p>A StackView (pinned to the margins of the UITableViewCells contentView) should allow me to control the height of the cell by manipulating the hidden property of the Views inside the StackView (much like shown here: <a href="https://stackoverflow.com/a/36250618/606730">https://stackoverflow.com/a/36250618/606730</a>)</p>
  
  <p>I have added the mandatory settings for dynamic height in the viewContoller like this:</p>
  
  <pre><code>self.tableView.rowHeight = UITableViewAutomaticDimension;
  self.tableView.estimatedRowHeight = 44;
  </code></pre>
  
  <p>I did not override heightForRowAtIndexPath as this is where I want auto layout to do the magic. </p>
  
  <p>My problem is that while the tableView is first loaded or the tableview is scrolling the cells are not seized correctly. But when I press inside a cell the height calculation does work and all the cells are shown in their correct height.</p>
  
  <p>I have overridden setSelected of the UITableViewCell like this:</p>
  
  <pre><code>-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
      [UIView setAnimationsEnabled:NO];
      [super setSelected:selected animated:animated];
      self.viewInsideStackView.hidden = !selected;
      [UIView setAnimationsEnabled:YES];
  }
  </code></pre>
  
  <p>This gets called as the tableview loads or scrolls for each cell. Manipulating 
  self.viewInsideStackView.hidden should make the stack view recalculate it's height. But this does not work. I also tried calling <code>layoutIfRequired</code> but still the wrong size appears until I press a cell.</p>