Daily iOS
UIKit

Dynamic cell height

You need a UITableView cell whose height varies with the length of a comment. What do you set up so the cell height fits its content automatically?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Set the table view's rowHeight to UITableView.automaticDimension and set estimatedRowHeight to turn on self-sizing. Then make the vertical constraints inside the cell's contentView an unbroken chain, and set the label's numberOfLines to 0 so it wraps.

Share a question