ios - 约束 objective-c
<p><p>什么意思</p>
<p>无法同时满足约束。可能以下列表中的至少一个约束是您不想要的。 </p>
<p>试试这个:
(1)查看每个约束并尝试找出您不期望的;
(2) 找到添加了一个或多个不需要的约束的代码并修复它。 </p>
<pre><code>(
"<NSLayoutConstraint:0x7f871d1303b0 H: >",
"<NSLayoutConstraint:0x7f871d1a1c40 H:>",
"<NSLayoutConstraint:0x7f871d1a4570 H:-(100.8)-| (Names: '|':UIView:0x7f871ac66870 )>",
"<NSLayoutConstraint:0x7f871d1a5200 H:|-(0)- (Names: '|':UIView:0x7f871ac66870 )>",
"<NSLayoutConstraint:0x7f871d19c5f0 H:-(0)-| (Names: '|':UIView:0x7f871d199d70 )>",
"<NSLayoutConstraint:0x7f871d19c640 H:|-(20)- (Names: '|':UIView:0x7f871d199d70 )>",
"<NSLayoutConstraint:0x7f871d1a8ca0 H:|-(0)- (Names: '|':UIView:0x7f871d199c00 )>",
"<NSLayoutConstraint:0x7f871d1a8d40 UIView:0x7f871d19c820.width == UIView:0x7f871d199d70.width>",
"<NSLayoutConstraint:0x7f871d1a8de0 H:-(10)->",
"<NSLayoutConstraint:0x7f871d1a8e80 H:-(10)->",
"<NSLayoutConstraint:0x7f871d1a8f20 UIView:0x7f871d1a7000.width == UIView:0x7f871d199d70.width>",
"<NSLayoutConstraint:0x7f871d1a8f70 H:-(0)-| (Names: '|':UIView:0x7f871d199c00 )>",
"<NSLayoutConstraint:0x7f871d1a9450 H:|-(15)- (Names: '|':UIView:0x7f871d19b130 )>",
"<NSLayoutConstraint:0x7f871d1a9540 H:-(10)->",
"<NSLayoutConstraint:0x7f871d1a95e0 H:-(10)->",
"<NSLayoutConstraint:0x7f871d1a96d0 H:-(10)-| (Names: '|':UIView:0x7f871d19b130 )>",
"<NSLayoutConstraint:0x7f871d1aa340 H:-(0)-| (Names: '|':UIView:0x7f871d19afc0 )>",
"<NSLayoutConstraint:0x7f871d1aa390 H:|-(0)- (Names: '|':UIView:0x7f871d19afc0 )>",
"<NSLayoutConstraint:0x7f871d1b7230 'UIView-Encapsulated-Layout-Width' H:>"
)
Will attempt to recover by breaking constraint
</code></pre>
<p></p>
<pre><code> 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.
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>这意味着您提供了比要求更多的约束,因此会产生歧义。 </p>
<p>例如,如果您有一个标签的高度为 <code>30</code>。</p>
<p>现在你给出 <code>top、leading 和 trailing 等约束,常量为 20</code> 和 <code>fixed height 为 30</code>。这意味着您的标签始终从顶部、左侧和右侧保持每侧 20 的空间,并始终保持 30 的高度。</p>
<p>没关系。</p>
<p>现在如果你添加另一个约束说 <code>fixed width with constant 50</code> 这意味着标签的宽度应该是 50。</p>
<p>现在如果您的应用在 4 英寸设备上运行,那么您的屏幕宽度为 320。</p>
<p>所以,如果标签保持宽度为 50 则不能保持左右间距为 20,如果它保持间距为 20 则不能保持宽度。</p>
<p>这种情况称为歧义。</p>
<p>这是一个理解的例子。</p>
<p>您的约束在某处造成了这种歧义,因此请检查两次并删除不必要或额外的约束。</p>
<p>希望这会有所帮助:)</p></p>
<p style="font-size: 20px;">关于ios - 约束 objective-c ,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/37526651/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/37526651/
</a>
</p>
页:
[1]