gpt4 book ai didi

iphone - 错误 : Unable to simultaneously satisfy constraints

转载 作者:行者123 更新时间:2023-12-01 18:20:14 24 4
gpt4 key购买 nike

我收到此错误:

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:0x1600aec0 V:[UIView:0x102021d0]-(0)-| (Names: '|':UIView:0x1600a980 )>",
"<NSLayoutConstraint:0x1600ae80 V:|-(494)-[UIView:0x102021d0] (Names: '|':UIView:0x1600a980 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1600e8a0 h=-&- v=-&- UIView:0x1600a980.height == UIWindow:0x9e0ea30.height>",
"<NSAutoresizingMaskLayoutConstraint:0x9e2d130 h=--- v=--- V:[UIWindow:0x9e0ea30(480)]>"
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1600aec0 V:[UIView:0x102021d0]-(0)-| (Names: '|':UIView:0x1600a980 )>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in
<UIKit/UIView.h> may also be helpful.

产生此错误的 View 对左/右/上/下有 4 个约束,我无法删除其中任何一个。

我试过了:
[View setTranslatesAutoresizingMaskIntoConstraints:NO];

没有结果。

你知道如何解决这个问题吗?

谢谢!

最佳答案

问题在于垂直布局。

<NSAutoresizingMaskLayoutConstraint:0x9e2d130 h=--- v=--- V:[UIWindow:0x9e0ea30(480)]>

自动调整窗口的蒙版。固定边距和大小。你无法改变这一点。
<NSAutoresizingMaskLayoutConstraint:0x1600e8a0 h=-&- v=-&- UIView:0x1600a980.height == UIWindow:0x9e0ea30.height>

自动调整掩码(固定边距,可调整大小的内容)。可能是您的 Controller 的 View 。高度为 480 (设置为等于窗口的大小)。这里没有什么可修复的。
<NSLayoutConstraint:0x1600aec0 V:[UIView:0x102021d0]-(0)-|   (Names:    '|':UIView:0x1600a980 )>
<NSLayoutConstraint:0x1600ae80 V:|-(494)-[UIView:0x102021d0] (Names: '|':UIView:0x1600a980 )>

您会注意到,两个约束都在使用相同的 View ( [UIView:0x102021d0]) 做某事,并且具有相同的第二个 View 作为参数 ( UIView:0x1600a980)。第二个 View 是我们 Controller 的 View 。

这两个约束定义了与第二个 View 边缘的距离。第一个定义底部( 0 )。第二个定义顶部( 494 )。如果superview的大小是 480 , 这意味着 [UIView:0x102021d0]高度等于 -14这会触发该异常。

如何解决?好吧,改变 494约束到正确的值。您甚至可能不想要“顶部”约束,也许您想要一个固定的高度。

问题是如何产生的?您可能为 iPhone 5 创建了约束,然后尝试使用 iPhone 4 运行应用程序。如果将 xib 中的模拟大小更改为 iPhone 4,您应该会立即看到问题。

关于iphone - 错误 : Unable to simultaneously satisfy constraints,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17844083/

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