滚动后(自动布局打开),将UICollectionViewCell中的属性文本UILabel切除。

为什么UITableViewCell中的相同设置可以正常工作。 (约束/优先级也相同)

使用自定义字体和自动换行

最佳答案

通过提供UILabel属性preferredMaxLayoutWidth的单元格宽度减去您在布局中使用的可能偏移量来解决此问题。

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

在这里找到答案:http://johnszumski.com/blog/auto-layout-for-table-view-cells-with-dynamic-heights

相似问题:Word Wrap not working for UILabelUILabel not wrapping text correctly sometimes (auto layout)

但是仍然存在一个问题,为什么我在UITableViewCell中不需要此属性

关于ios - 在UICollectionViewCell中截断了属性文本UILabel,但在UITableViewCell中截断了,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34901287/

10-10 21:04