David T.
David T.

Reputation: 23371

UITableViewCell height not updating when selected. using UITableViewAutomaticDimension

I'm having a hard time adjusting the height of my cell

I have a regular UITableView in which i return UITableViewAutomaticDimension for both -tableView:heightForRowAtIndexPath: and -tableView:estimatedHeightForRowAtIndexPath:. In each cell, i have a regular UIlabel. This works fine. However, when i select a cell, i add an image to the left of the cell, as well as make the font bigger. this sometimes can cause a line of text to flow over to the next line.

However, when the cell text overflows to 2 lines (instead of 1), it doesn't auto update the height of the cell.

How do i update the height of the cell according to the height of the content automatically?

Upvotes: 0

Views: 454

Answers (1)

Brandon Campbell
Brandon Campbell

Reputation: 394

Have you tried to reload that row after changing the layout? Unless something happens that triggers the table to recalculate the size of your cell the layout won't change.

Something like

tableView.reloadRows(at: [indexPath], with: UITableViewRowAnimation.none)

Upvotes: 1

Related Questions