title: Swift 4 UITableView Cell height not working
body: <p>I'm trying to set the height on Xcode9, except it doesn't seem to work. I can get away with a fixed size of 76. I have an Image in there which I want to have 10 padding with a height of 56.</p>
  
  <p>What I've tried:
  1. Setting it in the Size Inspector
  2. Through coding, but it's not working</p>
  
  <pre><code>override func viewDidLoad() {
      super.viewDidLoad()
      tableView.rowHeight = UITableViewAutomaticDimension
      self.tableView.estimatedRowHeight = 76
      getArticles() // returns json data
  }
  </code></pre>
  
  <p>And the tableView</p>
  
  <pre><code>    public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      guard let cell = tableView.dequeueReusableCell(withIdentifier: "ArticleCell") as? ArticleCell else { return UITableViewCell() }
  
      cell.titleLabel.text = articles[indexPath.row].title
  
      if let imageURL = URL(string: articles[indexPath.row].image) {
          DispatchQueue.global().async {
              let data = try? Data(contentsOf: imageURL)
              if let data = data {
                  let image = UIImage(data: data)
                  DispatchQueue.main.async {
                      cell.imgView.image = image
                  }
              }
          }
      }
  
      cell.contentView.setNeedsLayout()
      cell.contentView.layoutIfNeeded()
  
      return (cell)
  }
  </code></pre>
  
  <p>Nothing seems to work, and it stays at the same height. I have tried it with and without contraints.</p>
  
  <p>What am I doing wrong here?</p>
  
  <p><strong>EDIT</strong>
  I have changed from Prototype cell to Xib. Now I have it working, except of I get constraints errors.</p>
  
  <p><a href="https://i.stack.imgur.com/AdyNu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AdyNu.jpg" alt="The constraints setup"></a>
  This is the only way it works. If I remove the bottom margins, it goes back to the smaller size again. Same if I remove the image height.</p>
  
  <pre><code>    2017-09-25 19:26:37.842902+0200 Proj010916-NL_nl[56361:915542] [LayoutConstraints] Unable to simultaneously satisfy constraints.
      Probably at least one of the constraints in the following list is one you don't want. 
      Try this: 
          (1) look at each constraint and try to figure out which you don't expect; 
          (2) find the code that added the unwanted constraint or constraints and fix it. 
  (
      "&lt;NSLayoutConstraint:0x60c000093c90 UIImageView:0x7fec2800cd60.height == 56   (active)&gt;",
      "&lt;NSLayoutConstraint:0x60c000093ce0 UIImageView:0x7fec2800cd60.top == UITableViewCellContentView:0x7fec2800aa70.topMargin + 10   (active)&gt;",
      "&lt;NSLayoutConstraint:0x60c000093d80 UITableViewCellContentView:0x7fec2800aa70.bottomMargin == UIImageView:0x7fec2800cd60.bottom + 10   (active)&gt;",
      "&lt;NSLayoutConstraint:0x604000097160 'UIView-Encapsulated-Layout-Height' UITableViewCellContentView:0x7fec2800aa70.height == 92   (active)&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x60c000093c90 UIImageView:0x7fec2800cd60.height == 56   (active)&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful.
  </code></pre>
  
  <p>Next task is to redo the segue since it's now a vc and not a cell inside anymore.</p>