I am trying to make the cells inside my UITableView adapt to the length of the text in them. If the text is too long, the cell grow a bit taller to fit it.
I am trying something like this:
cell.textLabel.numberOfLines = 0;
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap;
cell.textLabel.text = [[name stringByAppendingString:@": "]
stringByAppendingString:comment];
But what happens is that the cell just tries to fit the text into same vertical amount of space, and does not get any taller.
Would anyone know what I am doing incorrectly here?
Thank you!
You need to use the cell height delegate. Take a look here: dynamic UITableViewCell height .
What you need to do is calculate the text height, and then set the cell’s height to that.
Specifically this method: