title: How to adjust the height of the header of a tableview in swift?
body: <p>I have a UITableViewController. This table view has an header view.
  I use main.storyboard with autolayout to set my controller.</p>
  
  <p>In my main.storyboard, for w:Any h:Any, the preview of my view controller is set with the default size 600x600. Inside, my header view is set to 600x200.</p>
  
  <p>In my header view, I have an imageView set to the Aspect Fill mode:</p>
  
  <p><img src="https://i.stack.imgur.com/2sneL.png" alt="main.storyboard"></p>
  
  <p>The constraints :</p>
  
  <p><img src="https://i.stack.imgur.com/8hVp4.png" alt="constraints"></p>
  
  <p>In the assets, my image has @2x and @3x sizes.</p>
  
  <ul>
  <li>header-image@2x.png -> 750x498</li>
  <li>header-image@3x.png -> 1242x825</li>
  </ul>
  
  <p>When I compile, in the simulator I obtain for iPhone 5: </p>
  
  <p><img src="https://i.stack.imgur.com/WUNHB.png" alt="IPH5"></p>
  
  <p>For iPhone 6: </p>
  
  <p><img src="https://i.stack.imgur.com/SQHMj.png" alt="IPH6"></p>
  
  <p>For iPhone 6+: </p>
  
  <p><img src="https://i.stack.imgur.com/lXrtf.png" alt="IPH6+"></p>
  
  <ul>
  <li>For the iPhone 5, the image starts below the status bar. I don't
  understand why? </li>
  <li>For the iPhone 6 and iPhone 6+, the image crops the first cell of my table view. And the top of the image isn't adjust with the top of the view.</li>
  </ul>
  
  <p>I don't know how to adjust the height of the tableHeaderView to the height of my image, because this height depends on the device.</p>
  
  <p>I have tried to set programmatically the frame of the header, in vain:</p>
  
  <pre><code> var frame:CGRect!
   frame.size.width = self.bgHeaderImageView.image?.size.width
   frame.size.height = self.bgHeaderImageView.image?.size.height
   self.tableView.tableHeaderView?.frame = frame
  </code></pre>
  
  <p>I got 2 errors : "Value optional type CGFloat? not unwrapped"</p>
  
  <p>And if I correct with </p>
  
  <pre><code> var frame:CGRect!
   frame.size.width = self.bgHeaderImageView.image?.size.width!
   frame.size.height = self.bgHeaderImageView.image?.size.height!
   self.tableView.tableHeaderView?.frame = frame
  </code></pre>
  
  <p>I got 2 errors : "Operand of postfix ! should have optional type"</p>
  
  <p>Is it to possible to adjust the size in the storyboard directly and not programmatically ?</p>
  
  <p>I'm probably missing something here...</p>