title: Incorrect UITableViewCell Height with Dynamic UILabels and Content Compression/Resistance
body: <p>Building on Xcode 7.2.1, iOS 9.2</p>
  
  <p>I have a <code>UITableView</code> with cells that have automatic height.</p>
  
  <pre><code>tableView.estimatedRowHeight = 80
  tableView.rowHeight = UITableViewAutomaticDimension
  </code></pre>
  
  <p>The layout of the cells is as follows:</p>
  
  <pre><code>UITableViewCell
    contentView
    outerStackView - pinned to top, left, right, bottom edges of the contentView with autolayout
      leftColumnStackView - 38% of width of outerStackView
         topStackView
           label UILabel
           value UILabel
         bottomStackView
           label UILabel
           value UILabel
      middleColumnStackView - 38% of width of outerStackView
        ...
      rightColumnStackView - rest of the width of outerStackView
        ...
  </code></pre>
  
  <p>The cells have 6 label/value pairs in them -- [Label X: Value]. Each label/value pair is comprised of 2 <code>UILabels</code>, with their content hugging and content compressions resistance attributes set accordingly to give the desired look.</p>
  
  <pre><code>label.numberOfLines = 0
  label.textAlignment = NSTextAlignment.Left
  label.setContentCompressionResistancePriority(1000, forAxis: .Horizontal)
  label.setContentHuggingPriority(1000, forAxis: .Horizontal)
  
  value.numberOfLines = 0
  value.setContentCompressionResistancePriority(500, forAxis: .Horizontal)
  value.setContentHuggingPriority(500, forAxis: .Horizontal)
  
  // there are 6 stack views, each containing a label/value pair
  // the stack views are .Horizontal alignment, and pinned to the 
  // columns they sit in
  stackView.addArrangedSubview(label)
  stackView.addArrangedSubview(value)
  </code></pre>
  
  <p>However, sometimes the cell height properly measures itself, and other times adds a bunch of extra space (interesting enough, the extra space is always equal to the space that <em>would</em> be there if the content compression/hugging wasn't added to either label).</p>
  
  <p>Here's the inconsistency that happens:</p>
  
  <p>Sometimes it's right:
  <a href="https://i.stack.imgur.com/62dyh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/62dyh.png" alt="enter image description here"></a></p>
  
  <p>Sometimes it's wrong:
  <a href="https://i.stack.imgur.com/iyINm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iyINm.png" alt="enter image description here"></a></p>
  
  <p>When I remove the content compression/resistance from the labels however, the cell is always the correct height, but looks like this:
  <a href="https://i.stack.imgur.com/gpUnh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gpUnh.png" alt="enter image description here"></a></p>
  
  <p>Anybody experienced similar? Have any suggestions?</p>