title: aspect ratio for imageView in dynamic tableViewCell
body: <p>I've got a tableView with 4 dynamic prototype cells: three of them for different kind of labels and one for an imageView.</p>
  
  <p>In viewDidLoad() I use this code to determine the height of each cell based on their content:</p>
  
  <pre><code>tableView.estimatedRowHeight = 100
  tableView.rowHeight = UITableViewAutomaticDimension
  </code></pre>
  
  <p>The problem is for the cell with the imageView. 
  The picture to be displayed occupies almost all the cell and it needs to be shown in landscape keeping it's aspect ratio.
  I was able to do it, setting top, bottom, trailing, leading and height constraints: in this way the tableView could calculate the appropriate row.height.</p>
  
  <p>Switching from iPhone 6 to 4, the image width is reduced but the height remains the same resulting in strange ratios.</p>
  
  <p>I need to calculate the eight of the view based on the width of the moment and I tried it in two ways:</p>
  
  <p>creating an NSLayoutConstraint outlet for the height. If I assign it a static value it works but when I try to calculate like:</p>
  
  <pre><code>constraintOutletForTheHeight.constant = CGFloat(myImageView.frame.size.width / 2)
  </code></pre>
  
  <p>it starts showing the first cells with the old value and the others appear with the computed height value.</p>
  
  <p>I also attempted setting the aspectRatio constraint from Storyboard but in both cases Xcode tells me that it can't simultaneously satisfy constraints.</p>
  
  <p>Thank you for your interest</p>