title: UITableViewAutomaticDimension works not as expected. Swift
body: <p>After reading Ray Wenderlich <a href="https://www.raywenderlich.com/1067-self-sizing-table-view-cells" rel="nofollow noreferrer">guide</a> for "Self-sizing Table View Cells" as well as <a href="https://stackoverflow.com/questions/30299319/why-uitableviewautomaticdimension-not-working">this question</a> and answers to it, I've decided to ask all of you for a help.</p>
  
  <p>Have a programmically created cell:</p>
  
  <pre><code>import UIKit
  
  class NotesCell: UITableViewCell {
  lazy private var cellCaption: UILabel = {
      let label = UILabel()
  
      label.translatesAutoresizingMaskIntoConstraints = false
      label.font = UIFont.systemFont(ofSize: 20, weight: UIFont.Weight.medium)
      label.numberOfLines = 0
      label.lineBreakMode = .byWordWrapping
  
      return label
  }()
  
  func configure(with note: NotesModel) {
      cellCaption.text = note.name
  
      contentView.addSubview(cellCaption)
  }
  
  override func layoutSubviews() {
      super.layoutSubviews()
  
      NSLayoutConstraint.activate([
          cellCaption.topAnchor.constraint(equalTo: contentView.topAnchor, constant: 8),
          cellCaption.leadingAnchor.constraint(equalTo: contentView.leadingAnchor, constant: 8),
          cellCaption.trailingAnchor.constraint(equalTo: contentView.trailingAnchor, constant: -8),
  //            cellCaption.bottomAnchor.constraint(equalTo: contentView.bottomAnchor, constant: -8),
  cellCaption.bottomAnchor.constraint(greaterThanOrEqualTo: contentView.bottomAnchor, constant: -8)
              ])
  
  //        cellCaption.sizeToFit()
  //        cellCaption.layoutIfNeeded()
  }
  }
  </code></pre>
  
  <p>The table view controller uses UITableViewAutomaticDimension in the delegate methods:</p>
  
  <pre><code>extension NotesTableViewController {
  override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {
      return UITableViewAutomaticDimension
  }
  
  override func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -&gt; CGFloat {
      return UITableViewAutomaticDimension
  }
  </code></pre>
  
  <p>}</p>
  
  <p>As a result, the longest caption is indicated fully, but the cell anyway has the same height as all other. </p>
  
  <p><a href="https://i.stack.imgur.com/MHCvR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MHCvR.png" alt="enter image description here"></a></p>
  
  <p>Some update!</p>
  
  <p>I've already tried to put into viewDidLoad() following code: </p>
  
  <pre><code>tableView.rowHeight = 44
  tableView.estimatedRowHeight = UITableViewAutomaticDimension
  </code></pre>
  
  <p>with enabling delegate methods and disabling them as well. The result is the same :(</p>