gpt4 book ai didi

ios - 奇怪的 UIView-Encapsulated-Layout-Height 错误

转载 作者:IT老高 更新时间:2023-10-28 11:44:35 29 4
gpt4 key购买 nike

我正在制作测试应用程序,所以在 Storyboard 的 tableviewCell 中,我有 imageViewwebView(用于显示 html-text 的 webview)。

我为 imageView 设置了 top/left/right/height=200 等约束,它们之间的间距 =5 以及 webView 的 left/right/bot,所以我想要以编程方式计算我的 webView 高度,然后更改单元格的高度以拉伸(stretch)我的 webView。但我明白了:

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 试图打破的约束的优先级来消除此警告。所以如果它说:

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

继续并将其优先级降低到 999

应该可以。

干杯。

关于ios - 奇怪的 UIView-Encapsulated-Layout-Height 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28410309/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com