当我的UIStackView“行”被压缩时,它们会抛出AutoLayout警告。但是,它们显示得很好,除了这类日志之外,没有什么是错误的:
不能同时满足约束。可能下面列表中至少有一个约束是您不想要的。尝试如下:(1)查看每个约束,并尝试找出您不期望的;(2)找到添加了不需要的约束的代码并修复它。(注意:如果您看到的是您不了解的
NSAutoresizingMaskLayoutConstraints,请参阅UIViewpropertytranslatesAutoresizingMaskIntoConstraints的文档)(
因此,我还不知道如何解决这个问题,但它似乎除了恼人之外,并没有破坏任何东西。
有人知道怎么解决吗?有趣的是,布局约束经常被标记为'UISV-hiding',,可能它应该忽略子视图或实例中的高度最小值?
发布于 2015-10-01 11:02:37
您之所以会遇到这个问题,是因为当将UIStackView内部的子视图设置为隐藏时,它首先会将其高度限制为零,以便将其动画化。
我得到了以下错误:
2015-10-01 11:45:13.732 <redacted>[64455:6368084] 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 and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSLayoutConstraint:0x7f7f5be18c80 V:[UISegmentedControl:0x7f7f5bec4180]-(8)-| (Names: '|':UIView:0x7f7f5be69d30 )>",
"<NSLayoutConstraint:0x7f7f5be508d0 V:|-(8)-[UISegmentedControl:0x7f7f5bec4180] (Names: '|':UIView:0x7f7f5be69d30 )>",
"<NSLayoutConstraint:0x7f7f5bdfbda0 'UISV-hiding' V:[UIView:0x7f7f5be69d30(0)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x7f7f5be18c80 V:[UISegmentedControl:0x7f7f5bec4180]-(8)-| (Names: '|':UIView:0x7f7f5be69d30 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.我想要做的是,在我的UIView中放置一个UIStackView,它在每条边界上都包含一个由8个UISegmentedControl嵌入的UISegmentedControl。
当我将它设置为隐藏时,它会尝试将容器视图约束为零高度,但是由于我有一组自上而下的约束,所以会出现冲突。
为了解决这个问题,我将我的8pt顶部的底部约束优先级从1000更改为999,这样如果需要的话,UISV-hiding约束可以获得优先级。
https://stackoverflow.com/questions/32428210
复制相似问题