title: How to change the cell height of inner table view cell in iOS?
body: <p>I have a dynamic table view inside a static table view. I am not able to change the cell height according to the cell content. I have tried various methods like</p>
  
  <pre><code>func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -&gt; CGFloat {
          return UITableView.automaticDimension
      }
  </code></pre>
  
  <pre><code>func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -&gt; CGFloat {
      if (ProfileData.profileViewType == .favourite) {
          if let cell = tableView.dequeueReusableCell(withIdentifier: "profileCell", for: indexPath) as? ProfileCell {  // gives EXC_BAD_ACCESS in SimpleCheckbox library
              cell.favouritesTitleLabel.numberOfLines = 0
              cell.favouritesTitleLabel.sizeToFit()
              print(cell.favouritesTitleLabel.text)
              let height = cell.favouritesTitleLabel.text!.height(withConstrainedWidth: cell.frame.width - 64, font: UIFont(name: "Roboto", size: 17.0)!)
              print(height + 16)
              return height + 16
          }
      }
      return UITableView.automaticDimension
  }
  </code></pre>
  
  <p>I have tried setting <code>UITableView.automaticDiemension</code>, but it is not adjusting to the text view. It is getting larger. If I try <code>tableView.dequeueReusableCell(withIdentifier: "profileCell") as! ProfileCell</code> I am getting only the contents of two cells and rest are not getting the text value.</p>
  
  <p>The current UI screenshot is:
  <a href="https://i.stack.imgur.com/NL0d4.png" rel="nofollow noreferrer">UI screenshot</a></p>
  
  <p>I have set the following table view config in <code>viewDidLoad()</code>:</p>
  
  <pre><code>profileTableView = ProfileSectionTableView()
  profileTableView.profileDelegate = self
  profileSectionTableView.delegate = profileTableView
  profileSectionTableView.dataSource = profileTableView
  profileSectionTableView.rowHeight = UITableView.automaticDimension
  profileSectionTableView.estimatedRowHeight = 44
  </code></pre>