UILabel autoLayout工作不正常

时间:2015-05-04 12:03:08

标签: ios objective-c autolayout

我在scope.$watch('basketHasChanged', function(newValue, oldValue) { //and update your View here manually }); 中设置了UIlabel我想动态地设置UITableViewCell的高度,所以我在UITableViewCell添加一些约束,当输入UILabel时},标签和UIViewController的高度不正确,但是如果我将UITableViewCell滚出屏幕并将其滚动回屏幕,那么它的工作正确,它是奇怪的。< / p>

这是我在故事板中的约束

enter image description here

输入UIViewController

时,在TableViewCell中输入UILabel

enter image description here

它应该是

enter image description here

我尝试添加代码(覆盖UILabel)

UITableViewCell

并将内容拥抱优先级设置为1000

4 个答案:

答案 0 :(得分:0)

您可以将约束作为IBOutlet连接到代码。因此,只需尝试使用UITableViewCell高度以编程方式更改的高度约束。

答案 1 :(得分:0)

发生这种情况是因为你的标签高度大于它的文字内容。如果你为它设置背景颜色,那么你可以看到它不会将标签的底部固定在单元格底部,它会拉伸标签高度。

enter image description here

或者你可以尝试

Once you know latency you can get processing time.

将字符串值设置为标签后,可以解决问题。

答案 2 :(得分:0)

将底部空间约束的优先级更改为&#34;低&#34;。它与拥抱内容的斗争

答案 3 :(得分:0)

根据您的要求使用这些约束:
标题标签: image1


文字标签:
textLabel.numberOfLines = 0;

image2

<强>输出

enter image description here
请点击这些链接AutolayoutAutolayout programatically