【问题标题】:Attributed text UILabel cut off in UICollectionViewCell but not in UITableViewCell属性文本 UILabel 在 UICollectionViewCell 中被切断,但在 UITableViewCell 中没有
【发布时间】:2016-01-20 13:23:31
【问题描述】:

UICollectionViewCell 中的属性文本 UILabel 在滚动后被截断(自动布局打开)。

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

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

【问题讨论】:

    标签: ios xcode autolayout uicollectionview uilabel


    【解决方案1】:

    通过提供 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 中不需要这个属性

    【讨论】:

      猜你喜欢
      • 2017-06-05
      • 2018-01-26
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-16
      相关资源
      最近更新 更多