UILabel在使用Autolayout时不会扩展其高度

时间:2016-07-01 17:04:43

标签: ios objective-c uitableview autolayout uilabel

在我的应用程序中,我有一个UITableViewCell,其中包含三个UILabel和一个自定义分隔符行UIView

这三个UILabels的内容完全dynamic,约为3-4行。

  

我的前两个标签工作正常但我的第三个标签没有增加它的高度。这是我的设置:

enter image description here

我的约束如下:

  

第一视图:

  Leading to Superview - Trailing to SuperView- Top to Super View - Bottom To Second View - Height > 30

  First Label:
  Leading to First View - Trailing to First View - Top To First View - Bottom to First View - Height=20 -  Width
  First Label Discription Label
  Leading to First View - Trailing to First View - Top to First View - Bottom to First View - Height > 20
  

第二视图:

  Leading to Superview - Trailing to SuperView- Top to First View - Bottom To Third View - Height > 30

  Second Label:
  Leading to Second View - Trailing to Second View - Top To Second View - Bottom to Second View - Height=20 -  Width
  Second View Discription Label
  Leading to Second View - Trailing to Second View - Top to Second View - Bottom to Second View - Height > 20
  

第三视图:

  Leading to Superview - Trailing to SuperView- Top to Second View - Bottom To SeparatorView  - Height > 30

  Th Label:
  Leading to Second View - Trailing to Second View - Top To Third View - Bottom to Third View - Height=20 -  Width
  Third View Discription Label
  Leading to Third View - Trailing to Third View - Top to Third View - Bottom to Third View - Height > 20
  

Separtaor View

        Leading to Super View - Super to Third View - Top to Third View - Bottom to  SuperView - Height =1

我在更新后正在调用-updateData()我正在调用[self.contentView layoutIfNeeded];

所有UILabel都有numberOfLines:10

这是输出:

enter image description here

我几乎尝试了所有可能的方式:

  [self updateConstraints];
    [self needsUpdateConstraints];
    [self setNeedsLayout]; and many more solutions available on SO.

但是无法制作第三个标签动态。请有人建议我做错了什么。

0 个答案:

没有答案