[英]iOS Auto Layout Unable to simultaneously satisfy constraints
My code snippet is as below 我的代码段如下
self.sortOptionsViewSmall.hidden = !self.sortOptionsViewSmall.hidden;
self.sortOptionsView.hidden=YES;
[UIView animateWithDuration:0.4 animations:^{
**self.sortViewHeightSmall.constant = (self.sortViewHeightSmall.constant == 0) ? 187 : 0;**
self.sortViewHeightConstraint.constant = (self.sortViewHeightSmall.constant == 187) ? 187 : 0;
self.tableViewHeightConstraint.constant = self.sortViewHeightSmall.constant == 0 ? 664 : 477;
[self.view layoutIfNeeded];
}];
If I navigate to some other view and navigate back the 如果我导航到其他视图并向后导航,
self.sortViewHeightSmall.constant = (self.sortViewHeightSmall.constant == 0) ? 187 : 0;
gives me below error 给我下面的错误
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:0x181643e0 V:[SortOptionsView:0x18162970(187)]>",
"<NSLayoutConstraint:0x18162ac0 V:[SortOptionsView:0x18162010(0)]>",
"<NSLayoutConstraint:0x18155170 V:[SortOptionsView:0x18162970]-(0)-
[UITableView:0xea98e00]>",
"<NSLayoutConstraint:0x181551a0 V:[SortOptionsView:0x18162010]-(0)-
[UITableView:0xea98e00]>",
"<NSLayoutConstraint:0x18155260 V:[UIView:0x181544e0]-(0)-
[SortOptionsView:0x18162010]>",
"<NSLayoutConstraint:0x18155290 V:[UIView:0x181544e0]-(0)-
[SortOptionsView:0x18162970]>"
)
Will attempt to recover by breaking constraint 将尝试通过打破约束来恢复
<NSLayoutConstraint:0x181643e0 V:[SortOptionsView:0x18162970(187)]>
Break on objc_exception_throw
to catch this in the debugger. 中断
objc_exception_throw
以在调试器中捕获此错误。 The methods in the UIConstraintBasedLayoutDebugging
category on UIView
listed in <UIKit/UIView.h>
may also be helpful. <UIKit/UIView.h>
列出的UIView
的UIConstraintBasedLayoutDebugging
类别中的方法也可能会有所帮助。 this error.** 此错误。**
I tried to use setTranslatesAutoresizingMaskIntoConstraints:NO
but it is not working. 我尝试使用
setTranslatesAutoresizingMaskIntoConstraints:NO
但是它不起作用。
Any help is appreciated. 任何帮助表示赞赏。
Check your code. 检查您的代码。 In error stack i see two constraits with conflict:
在错误堆栈中,我看到两个冲突的环境:
"<NSLayoutConstraint:0x181643e0 V:[SortOptionsView:0x18162970(187)]>",
"<NSLayoutConstraint:0x18162ac0 V:[SortOptionsView:0x18162010(0)]>",
SortOptionsView can't understand, what will be it height size 187 points or 0? SortOptionsView无法理解,高度大小为187点或0是什么? You can resolve this conflict with 2 ways:
您可以通过以下两种方法解决此冲突:
I hope i sent you on the right path. 我希望我以正确的方式送你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.