首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >“压缩”隐藏视图上的UIStackView“不能同时满足约束”

“压缩”隐藏视图上的UIStackView“不能同时满足约束”
EN

Stack Overflow用户
提问于 2015-09-06 20:54:05
回答 14查看 29.9K关注 0票数 101

当我的UIStackView“行”被压缩时,它们会抛出AutoLayout警告。但是,它们显示得很好,除了这类日志之外,没有什么是错误的:

不能同时满足约束。可能下面列表中至少有一个约束是您不想要的。尝试如下:(1)查看每个约束,并尝试找出您不期望的;(2)找到添加了不需要的约束的代码并修复它。(注意:如果您看到的是您不了解的NSAutoresizingMaskLayoutConstraints,请参阅UIView property translatesAutoresizingMaskIntoConstraints的文档)(

因此,我还不知道如何解决这个问题,但它似乎除了恼人之外,并没有破坏任何东西。

有人知道怎么解决吗?有趣的是,布局约束经常被标记为'UISV-hiding',,可能它应该忽略子视图或实例中的高度最小值?

EN

Stack Overflow用户

回答已采纳

发布于 2015-10-01 11:02:37

您之所以会遇到这个问题,是因为当将UIStackView内部的子视图设置为隐藏时,它首先会将其高度限制为零,以便将其动画化。

我得到了以下错误:

代码语言:javascript
运行
复制
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约束可以获得优先级。

票数 212
EN
查看全部 14 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32428210

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档