什么意思
无法同时满足约束。可能以下列表中的至少一个约束是您不想要的。
试试这个: (1)查看每个约束并尝试找出您不期望的; (2) 找到添加了一个或多个不需要的约束的代码并修复它。
(
"<NSLayoutConstraint:0x7f871d1303b0 H: [UIButton:0x7f871d197640(30)]>",
"<NSLayoutConstraint:0x7f871d1a1c40 H:[UIButton:0x7f871d196960'LB'(30)]>",
"<NSLayoutConstraint:0x7f871d1a4570 H:[UIView:0x7f871d196d60]-(100.8)-| (Names: '|':UIView:0x7f871ac66870 )>",
"<NSLayoutConstraint:0x7f871d1a5200 H:|-(0)-[UIView:0x7f871d196d60] (Names: '|':UIView:0x7f871ac66870 )>",
"<NSLayoutConstraint:0x7f871d19c5f0 H:[UIView:0x7f871ac66870]-(0)-| (Names: '|':UIView:0x7f871d199d70 )>",
"<NSLayoutConstraint:0x7f871d19c640 H:|-(20)-[UIView:0x7f871ac66870] (Names: '|':UIView:0x7f871d199d70 )>",
"<NSLayoutConstraint:0x7f871d1a8ca0 H:|-(0)-[UIView:0x7f871d199d70] (Names: '|':UIView:0x7f871d199c00 )>",
"<NSLayoutConstraint:0x7f871d1a8d40 UIView:0x7f871d19c820.width == UIView:0x7f871d199d70.width>",
"<NSLayoutConstraint:0x7f871d1a8de0 H:[UIView:0x7f871d199d70]-(10)-[UIView:0x7f871d19c820]>",
"<NSLayoutConstraint:0x7f871d1a8e80 H:[UIView:0x7f871d19c820]-(10)-[UIView:0x7f871d1a7000]>",
"<NSLayoutConstraint:0x7f871d1a8f20 UIView:0x7f871d1a7000.width == UIView:0x7f871d199d70.width>",
"<NSLayoutConstraint:0x7f871d1a8f70 H:[UIView:0x7f871d1a7000]-(0)-| (Names: '|':UIView:0x7f871d199c00 )>",
"<NSLayoutConstraint:0x7f871d1a9450 H:|-(15)-[UIButton:0x7f871d197640] (Names: '|':UIView:0x7f871d19b130 )>",
"<NSLayoutConstraint:0x7f871d1a9540 H:[UIButton:0x7f871d197640]-(10)-[UIView:0x7f871d199c00]>",
"<NSLayoutConstraint:0x7f871d1a95e0 H:[UIView:0x7f871d199c00]-(10)-[UIButton:0x7f871d196960'LB']>",
"<NSLayoutConstraint:0x7f871d1a96d0 H:[UIButton:0x7f871d196960'LB']-(10)-| (Names: '|':UIView:0x7f871d19b130 )>",
"<NSLayoutConstraint:0x7f871d1aa340 H:[UIView:0x7f871d19b130]-(0)-| (Names: '|':UIView:0x7f871d19afc0 )>",
"<NSLayoutConstraint:0x7f871d1aa390 H:|-(0)-[UIView:0x7f871d19b130] (Names: '|':UIView:0x7f871d19afc0 )>",
"<NSLayoutConstraint:0x7f871d1b7230 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f871d19afc0(320)]>"
)
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 <UIKit/UIView.h> may also be helpful.
这意味着您提供了比要求更多的约束,因此会产生歧义。
例如,如果您有一个标签的高度为 30
。
现在你给出 top、leading 和 trailing 等约束,常量为 20
和 fixed height 为 30
。这意味着您的标签始终从顶部、左侧和右侧保持每侧 20 的空间,并始终保持 30 的高度。
没关系。
现在如果你添加另一个约束说 fixed width with constant 50
这意味着标签的宽度应该是 50。
现在如果您的应用在 4 英寸设备上运行,那么您的屏幕宽度为 320。
所以,如果标签保持宽度为 50 则不能保持左右间距为 20,如果它保持间距为 20 则不能保持宽度。
这种情况称为歧义。
这是一个理解的例子。
您的约束在某处造成了这种歧义,因此请检查两次并删除不必要或额外的约束。
希望这会有所帮助
关于ios - 约束 objective-c ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37526651/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (https://ogeek.cn/) | Powered by Discuz! X3.4 |