title: Resizing UIStackView after changing UILabel number of lines
body: <p>My iOS app has a tableview with one UITableViewCell with the following layout (1 stackview containing 2 labels and 1 button)</p>
  
  <p><a href="https://i.stack.imgur.com/G2cv5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/G2cv5.png" alt="enter image description here"></a></p>
  
  <p>When the user taps the button the number of lines of the central label goes from 0 to 2 and will look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/wiDxs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wiDxs.png" alt="enter image description here"></a></p>
  
  <p>Now there are two problems here: </p>
  
  <p>1) Resizing the UIStackView</p>
  
  <p>2) Resizing the cell</p>
  
  <p>I have found a not-optimal solution for problem 1, which consists of adding an empty view in the stack. (invalidateIntrinsicContentSize was not working).</p>
  
  <pre><code>let emptyView = UIView()
  emptyView.frame = CGRect(x: 0, y: 0, width: 0, height: 0)
  stackView.addArrangedSubview(emptyView)
  </code></pre>
  
  <p>As you can see in the second screenshot the cell doesn't resize and I'm not sure if this is due to the stackview or the cell itself.</p>
  
  <p>I would like to point the fact that I'm writing code inside the UITableViewCell subclass as the button event is handled inside it.</p>
  
  <p>For the records The Tableview is using dynamic sizing:</p>
  
  <pre><code>// dynamic cell sizing 
  func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {
  
      return UITableViewAutomaticDimension
  }
  
  func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -&gt; CGFloat {
  
      return CGFloat(cellEstimatedHeight)
  }
  </code></pre>