控制台中的约束警告

Constraints warning in console

我是自动布局和约束方面的新手。所以我根据故事板的超级视图应用了约束,但面临以下警告:

"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. ( "<_UILayoutSupportConstraint:0x14dfa550 V:[_UILayoutGuide:0x14df81e0(0)]>", "<_UILayoutSupportConstraint:0x14dfa520 V:|-(0)-[_UILayoutGuide:0x14df81e0] (Names: '|':UIView:0x14ed7ff0 )>", "", "", "", "", "" )

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. 2016-08-01 11:56:48.694 Laatli[1034:623262] 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. ( "", "", "", "", "", "", "" )

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. 2016-08-01 11:56:48.699 Laatli[1034:623262] 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. ( "<_UILayoutSupportConstraint:0x14dfa550 V:[_UILayoutGuide:0x14df81e0(64)]>", "<_UILayoutSupportConstraint:0x14dfa520 V:|-(0)-[_UILayoutGuide:0x14df81e0] (Names: '|':UIView:0x14ed7ff0 )>", "", "", "", "", "", "" )

Will attempt to recover by breaking constraint

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful."

我不知道为什么这些警告会出现在控制台中。

无法满足的布局

当系统无法找到当前约束集的有效解决方案时,就会出现无法满足的布局。两个或多个必需的约束冲突,因为它们不能同时全部为真。

识别无法满足的约束

通常,Interface Builder 可以在设计时检测到冲突。在这些情况下,Interface builder 会以多种方式显示错误:

  • 所有冲突的约束都画在红色的canvas上。

  • Xcode 将冲突约束列为问题中的警告 导航器.

  • Interface Builder 在右上角显示一个红色的公开箭头 文档大纲的一角。

单击显示箭头可显示当前布局中所有自动布局问题的列表。

Interface Builder 通常可以针对这些问题提出修复建议。有关详细信息,请参阅 Resolving Layout Issues for a View Controller, Window, or Root View in Auto Layout Help.

下面是 link,其中 Apple 指定了所有这些。请务必阅读文档。它包含初学者可能想要的大部分答案。

来源:Apple Documentation

xCode 中显示的控制台错误的解释:-

"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. ( "<_UILayoutSupportConstraint:0x14dfa550 V:[_UILayoutGuide:0x14df81e0(0)]>", "<_UILayoutSupportConstraint:0x14dfa520 V:|-(0)-[_UILayoutGuide:0x14df81e0](名称:'| ':UIView:0x14ed7ff0 )>", "", "", "", "", "" )

意思是:-

一个视图中添加了一些额外的约束。与垂直相关的约束,即从顶部你给出了两个产生问题的约束。

它会自动删除任何满足条件的约束。

您需要删除任何一个约束并对 UIView 应用适当的有效约束。