奇怪的 UIView-Encapsulated-Layout-Height 错误 [英] Strange UIView-Encapsulated-Layout-Height Error

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

问题描述

我正在制作测试应用程序,所以在故事板的 tableviewCell 中,我有 imageView &webView(显示 html 文本的 webview).

I'm making test application, so in my tableviewCell in storyboard I have imageView & webView (webview to show html-text).

我为 imageView 设置了像 top/left/right/height=200 这样的约束,它们之间的间距=5 &webView 的左/右/bot,所以我想以编程方式计算我的 webView 高度,然后更改单元格的高度以拉伸我的 webView.但我得到了这个:

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 height to stretch my webView. But I got this :

Unable to simultaneously satisfy constraints.

Probably at least one of the constraints in the following list is one you don't want.

Try 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-Encapsulated-Layout-Height 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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