Resize UITableViewCell containing UITextView upon typing

后端 未结 11 2140
感动是毒
感动是毒 2020-12-23 10:19

I have an UITableViewController that contains a custom cell. Each cell was created using a nib and contains a single non-scrollable UITextView. I have added constraints insi

11条回答
  •  无人及你
    2020-12-23 10:56

    The solution almost everyone suggested is the way to go, I will add only a minor improvement. As a recap:

    1. Simply set the estimated height, I do it via storyboard:

    2. Make sure you have the constraints for the UITextView correctly set within the cell.

    3. In the func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell

    I simply call: cell.myTextView.sizeToFit()

提交回复
热议问题