简体   繁体   English

自动版式:无法同时满足约束条件日志不明确

[英]AutoLayout: Unable to simultaneously satisfy constraints log unclear

I'm getting the usual Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. ... 我越来越Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. ... Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. ... Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. ... warning in the console. Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. ...控制台中的警告。

One of the constraints in the list is: 列表中的约束之一是:

"<NSLayoutConstraint:0x7fe7bda00ff0 MyView:0x7fe7bbc934f0.height ==>"

Now, the meaning of the warning itself is pretty clear: some of the constraints are clashing and the engine is unable to satisfy all of them. 现在,警告本身的含义非常清楚:某些约束正在冲突,引擎无法满足所有约束。 This is pretty common when setting constraints via code, as I'm doing in this instance. 通过代码设置约束时,这很常见,就像我在本例中所做的那样。

What's not clear to me is the meaning of that specific constraint. 我不清楚那个特定约束的含义。 What does the missing right part of the equality means? 平等缺失的右边部分意味着什么?

My guess is that is means that the height depends on the constraints set by its subviews. 我的猜测是, height取决于其子视图设置的约束。 Is this correct? 这个对吗?

In your constraints there is an extra constraints that not require. 在您的约束中,有不需要的额外约束。

For example, 例如,

Suppose you given a constraints to leading and trailing and also you are giving a width constraints that this will lead to the warning to the compiler. 假设您对前导和尾随给出了约束,并且还给出了宽度约束,这将导致警告编译器。 because either you need a constraints for width or trailing constraints otherwise compiler will confuse what to take width or trailing. 因为您需要一个宽度约束或尾随约束,否则编译器会混淆采用宽度或尾随的内容。

For auto layout you need to remember one thing for any view you need to make constrains like this that compiler knows about view x , y , width and height. 对于自动布局,您需要为任何视图记住一件事情,您需要对编译器知道的x,y,width和height这样的约束进行约束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM