title: AutoLayout - Keep Ratio of Image With Horizontal Constraints (Swift Xcode 6)
body: <p>I've been trying to implement a timeline of picture (as instagram or facebook).
  However, I've been struggling with the ratio of the image.</p>
  
  <p>Here's my xib that contains my Cell :
  <img src="https://i.stack.imgur.com/jr3wj.png" alt="enter image description here"></p>
  
  <p>I want the picture to keep its ratio and to completely fill the width of the cell.
  I've set 4 autolayout constraint on the UIImageView as 0-0 for horizontal constraint and 5-5 for top/bottom constraints. I've also set the ViewMode to "Aspect Fit".</p>
  
  <p>I've tried different setup :</p>
  
  <ol>
  <li>set the height of UIImageView to a specific value :
  --> The width of the image is modify to keep the image ratio</li>
  <li>don't set the height of UIImageView
  --> it considers that the height is equal to 0 and therefore doesn't even display the image</li>
  <li>set the height greater or equal to a specific value :
  -- > same behavior as 1. (The width of the image is modify to keep the image ratio)</li>
  </ol>
  
  <p>I'm loading the image from an URL so I've been using the lib Haneke (<a href="https://github.com/Haneke/HanekeSwift" rel="nofollow noreferrer">https://github.com/Haneke/HanekeSwift</a>) with the following function :
  imageView.hnk_setImageFromURL(url).</p>
  
  <p>It has an automatic resize of the image and I don't know how to get the original width/height of the image to set the height manually.</p>
  
  <p>Again, what I want is the picture to keep its ratio and to completely fill the width of the cell.</p>
  
  <p>Anyone has a suggestion ?</p>
  
  <p>Thanks a lot !</p>