奇怪的UIView封装的布局高度错误 [英] Strange UIView-Encapsulated-Layout-Height Error

查看:244
本文介绍了奇怪的UIView封装的布局高度错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做测试应用程序,所以在我的tableviewCell在故事板我有imageView& webView(用于显示html文本)。我设置约束像top / left / right / height = 200 for imageView,spacing = 5之间他们&左/右/ bot for webView,所以我想计算我的webView高度编程,然后更改单元格的高度拉伸我的webView。但我得到了:

I'm making test application, so in my tableviewCell in storyboard i have imageView & webView (for show html-text). I set constraints like top/left/right/height=200 for imageView, spacing=5 between them & left/right/bot for webView, so i want to calculate my webView height programmatically and then change cell's heigt to stretch my webView. But i got this :

无法同时满足约束。

可能至少有一个约束

请尝试以下操作:

(1) look at each constraint and try to figure out which you don't expect;
(2) find the code that added the unwanted constraint or constraints & fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property

translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x7fd6f3773f90 V:[UIImageView:0x7fd6f3773e90(200)]>",
    "<NSLayoutConstraint:0x7fd6f3774280 UIImageView:0x7fd6f3773e90.top == UITableViewCellContentView:0x7fd6f3462710.topMargin>",
    "<NSLayoutConstraint:0x7fd6f3774320 V:[UIImageView:0x7fd6f3773e90]-(5)-[UIWebView:0x7fd6f3462800]>",
    "<NSLayoutConstraint:0x7fd6f3774370 UITableViewCellContentView:0x7fd6f3462710.bottomMargin == UIWebView:0x7fd6f3462800.bottom>",
    "<NSLayoutConstraint:0x7fd6f375ee40 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7fd6f3462710(205)]>"
)

有什么建议?

推荐答案

我通常通过降低约束的优先级移除此警告 AutoLayout 尝试中断。所以,如果这样说的:

I usually remove this warning by lowering the priority of the constraint that AutoLayout is trying to break. So if it says:

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fd7c2ecb520 V:[UIView:0x7fd7c2ecd0e0(300)]>

继续将其优先级降至 999

Go ahead and lower that one's priority to 999.

这应该可以工作。

干杯。

这篇关于奇怪的UIView封装的布局高度错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆