简体   繁体   中英

Is there a way to change tableView cell's height, when the label text in it is modified?

So I have a custom UITableViewCell class and a label in it. I want to autoresize the cell's height when the label text is modified and I've already tried to remove the heightForRowAt data source method and add 'tableView.estimatedRowHeight = 44.0 and tableView.estimatedRowHeight = 44.0` but it doesn't work. How can I achieve it?

Configure your tableView like that:

tableView.rowHeight = UITableView.automaticDimension
tableView.estimatedRowHeight = 44.0

And make sure your constraints are correctly set and your label as numberOfLines = 0

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM