Why are the layered UILabels in my UITableViewCell truncated on first load, but fixed when scrolling?

I had a problem with one of my table views in my application and am wondering if anyone has encountered something like this. I have 2 labels in the tableviewcell user table - a questionLabeland answerLabel- which have the following restrictions:

enter image description here enter image description here

On both UILabels, I have the number of lines set to 0 to make them multi-line and have added a property preferredmaxLayoutWidthfor both:

cell.questionLabel.preferredMaxLayoutWidth = cell.questionLabel.frame.width
cell.answerLabel.preferredMaxLayoutWidth = cell.answerLabel.frame.width

I also have a method viewDidLoad(), as in other StackOverflow sentences:

self.faqTableView.rowHeight = UITableViewAutomaticDimension
self.faqTableView.estimatedRowHeight = 140.00

- , 0 . , , . :

enter image description here

- , . , , , .

+4
1

enter image description here

enter image description here

, .

cell.questionLabel.preferredMaxLayoutWidth = cell.questionLabel.frame.width
cell.answerLabel.preferredMaxLayoutWidth = cell.answerLabel.frame.width
self.faqTableView.estimatedRowHeight = 140.00

UILabel .

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewAutomaticDimension;
}
+2

Source: https://habr.com/ru/post/1693184/


All Articles