Resizing UITextView in custom UITableViewCell

后端 未结 6 1596
天命终不由人
天命终不由人 2021-01-19 23:55

I have a custom UITableViewCell and I\'m trying to resize the UITextView inside it based on the content size. I\'m on iOS7 and using Autolayout.

6条回答
  •  清歌不尽
    2021-01-20 00:25

    Your layout is a bit more complex, but it should not matter if everything is set up properly.

    You do not have to calculate anything (by using sizeThatFits).

    All you have to do is disable UITextView's scrolling enabled property then on textViewDidChange call tableView.beginUpdates() and tableView.endUpdates(). That doesn't break the first responder and resizes the table view smoothly.

    For a detailed explanation, check out a post I wrote which also includes a working sample project.

提交回复
热议问题