gpt4 book ai didi

ios - "Unable to simultaneously satisfy constraints"隐藏 View 上的 UIStackView "squished"

转载 作者:IT王子 更新时间:2023-10-29 07:30:07 27 4
gpt4 key购买 nike

当我的 UIStackView“行”被压扁时,它们会抛出 AutoLayout 警告。但是,它们显示正常,除了这些类型的日志之外没有其他错误:

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) (

所以,我还不确定如何解决这个问题,但它似乎并没有破坏任何东西,除了很烦人之外。

有谁知道怎么解决吗?有趣的是,布局约束经常被标记为'UISV-hiding',表明在这种情况下它可能应该忽略 subview 或其他东西的高度最小值?

最佳答案

您会遇到此问题,因为当从 UIStackView 中将 subview 设置为隐藏时,它会首先将其高度限制为零,以便将其动画化。

我遇到了以下错误:

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.

我想做的是在我的 UIStackView 中放置一个 UIView,其中包含一个 UISegmentedControl 在每条边上插入 8pts。

当我将其设置为隐藏时,它会尝试将容器 View 约束为零高度,但因为我有一组从上到下的约束,所以发生了冲突。

为了解决这个问题,我将我的 8pt 顶部和底部约束优先级从 1000 更改为 999,以便 UISV-hiding 约束可以在需要时优先。

关于ios - "Unable to simultaneously satisfy constraints"隐藏 View 上的 UIStackView "squished",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32428210/

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