2
votes

Attributed text UILabel inside a UICollectionViewCell is cut off after scrolling (autolayout turned on).

Why does the same setup in a UITableViewCell is working fine. (the constraints / priority levels are identical as well)

Using a custom font & word wrap

1

1 Answers

3
votes

Resolved it by providing the cell width for the UILabel property preferredMaxLayoutWidth minus possible offsets you are using in your layout.

self.yourUIlabel.preferredMaxLayoutWidth = CGRectGetWidth(self.bounds) - yourOffsets;

Found the answer here: http://johnszumski.com/blog/auto-layout-for-table-view-cells-with-dynamic-heights

Similar questions: Word Wrap not working for UILabel & UILabel not wrapping text correctly sometimes (auto layout)

But some question remains why I didn't need this property inside the UITableViewCell