Reputation: 141
I have an issue with auto-sizing cells in tableview and wondering if anyone has any suggestions for me. I have a label that I set with text. I have Lines set to 0 in IB. I have also included
override func viewDidLoad() {
super.viewDidLoad()
tableView.rowHeight = UITableViewAutomaticDimension
tableView.estimatedRowHeight = 90
tableView.allowsSelection = true
}
When i scroll down to more cells. SOMETIMES, most of the time, the label does not update its size to include the whole text.
I set the text after in a background thread after I fetch using firebase, I am using firebase and parse. After I set the text, I have:
postCell.updateConstraints()
postCell.layoutIfNeeded()
Any ideas? THANKS Screenshot1 Screenshot2
Upvotes: 2
Views: 1536
Reputation: 6369
Self-Size-Cell is very strict with constraints. For example, your cell has a label. You should make constraints to cell top, bottom, left and right. Or if you fixed label's width, you don't need to make constraints to left and right. In another words, OS must be able to calculate the exact sizes of cell and its subviews. So check your constraints.
Upvotes: 1