Dynamically change cell's height while typing text, and reload the containing tableview for resize

假装没事ソ 提交于 2019-12-06 04:27:25

Using tableView's [tableView beginUpdates] and [tableView endUpdates] will solve this issue. See this answer for more information.

Set delegate On Your UITableViewCell like that

var textDidChanges: (() -> Void)? = nil

func textViewDidChange(_ textView: UITextView) {
    textDidChanges?()
}

and Your tableView cellForRowAt

cell.textDidChanges = {
    self.tableView.beginUpdates()
    self.tableView.endUpdates()
} 

How to make a UITableViewCell with a UITextView inside, that dynamically adjust its height, on the basis of the UITextView?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!