SizeWithFont - strange behavior when using the & symbol

Whenever the text is present and present in the text, getting the height seems to be turned off all the time. Both functions return less than the actual height:

CGSize labelSize = [nameLabel.text sizeWithFont:nameLabel.font constrainedToSize: CGSizeMake( actualWidth, MAXFLOAT ) lineBreakMode:UILineBreakModeWordWrap];

CGRect textSize = CGRectMake(0.0, 0.0, 320.0, FLT_MAX);
nameLabel.frame = [nameLabel textRectForBounds:textSize limitedToNumberOfLines:0];

None of them will return the correct height, although the second method using textRectForBounds returns a much closer actual height. The first will return 240, and later will return 700. Actually 750.

This will ruin my UITableView by showing texts overlapping with each other.

Interestingly, it would return the same height as long as the text does not contain any characters and characters.

Can someone enlighten me, please, as regards the life of me, I do not understand what is happening here, and I know how to fix it correctly.

Thanks for that in advance.

+3
2

-textRectForBounds:limitedToNumberOfLines: ( docs). . , " UITableViewCell , ".

, actualWidth sizeWithFont:constrainedToSize:lineBreakMode: , , . actualWidth?

, sizeWithFont:forWidth:lineBreakMode:, , . , , .

+2

. , , . UILabel , , .

+1

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


All Articles