E-Madd
E-Madd

Reputation: 4582

UITableView rowHeight UITableViewAutomaticDimension cell wrong height after first load

I've got a UITableViewCell subclass that has two labels of variable height. AFAIK, the autolayout constraints are correct. The first time the cell is rendered in the table it's correct, but any subsequent rendering is blown out too tall. Even after the parent view controller is deallocated! It literally requires an app restart to go back to normal.

I've tried clearing text of the labels in an override of prepareForReuse in the cell class.

// viewDidLoad tableView.rowHeight = UITableViewAutomaticDimension tableView.estimatedRowHeight = 300

enter image description here

Upvotes: 0

Views: 672

Answers (2)

Hussain Shabbir
Hussain Shabbir

Reputation: 15035

Sounds like your bottom constraint of UILabel is getting increased. Check if you are updating the bottom constraint constant value.

Upvotes: 0

Puneet Sharma
Puneet Sharma

Reputation: 9484

To support dynamic layout with textview, a height constraint is needed and that needs to be updated in layoutSubviews method(you need to subclass UITextview).

In addition to this, you need to make sure you have a UITextview bottom constraint with cell's contentView.

Upvotes: 0

Related Questions