2

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

Wojtek Dmyszewicz
  • 4,188
  • 5
  • 30
  • 42

1 Answers1

3

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

Community
  • 1
  • 1
Wojtek Dmyszewicz
  • 4,188
  • 5
  • 30
  • 42