title: Resize table header when using dynamic types
body: <p>I have a <code>TableViewController</code> with a header. 
  This header is a container, which links to another storyboard named <code>Header.storyboard</code></p>
  
  <p><a href="https://i.stack.imgur.com/5b0CQ.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/5b0CQ.jpg" alt="TableViewController"></a></p>
  
  <p><code>Header.storyboard</code> contains a stack view with some labels, that are dynamically typed. </p>
  
  <p>Labels text comes from DB.</p>
  
  <p>No regards to the text dimension or size I want to visualise it correctly.</p>
  
  <p><a href="https://i.stack.imgur.com/CVa7B.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/CVa7B.jpg" alt="enter image description here"></a></p>
  
  <p>I've used some answers from SO to get the header correctly resize, but without luck:</p>
  
  <pre><code>import UIKit
  
  class TableViewController: UITableViewController {
  
      @IBOutlet weak var tableHeaderView: UIView!
  
      override func viewDidLayoutSubviews() {
          super.viewDidLayoutSubviews()
  
          // Dynamic sizing for the header view
          if let headerView = tableHeaderView {
              headerView.setNeedsLayout()
              headerView.layoutIfNeeded()
  
              let height = headerView.systemLayoutSizeFitting(UILayoutFittingCompressedSize).height
              var headerFrame = headerView.frame
  
              // If we don't have this check, viewDidLayoutSubviews() will get
              // repeatedly, causing the app to hang.
              if height != headerFrame.size.height {
                  headerFrame.size.height = height
                  headerView.frame = headerFrame
                  tableHeaderView = headerView
             }
         }
     }
  }
  </code></pre>