【发布时间】:2016-01-20 13:23:31
【问题描述】:
UICollectionViewCell 中的属性文本 UILabel 在滚动后被截断(自动布局打开)。
为什么 UITableViewCell 中的相同设置工作正常。 (约束/优先级也相同)
使用自定义字体和自动换行
【问题讨论】:
标签: ios xcode autolayout uicollectionview uilabel
UICollectionViewCell 中的属性文本 UILabel 在滚动后被截断(自动布局打开)。
为什么 UITableViewCell 中的相同设置工作正常。 (约束/优先级也相同)
使用自定义字体和自动换行
【问题讨论】:
标签: ios xcode autolayout uicollectionview uilabel
通过提供 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 UILabel & UILabel not wrapping text correctly sometimes (auto layout)
但仍然存在一些问题,为什么我在 UITableViewCell 中不需要这个属性
【讨论】: