我正在移动一些视图以编程方式更改其约束,在某些时候我得到了这个:
2013-11-12 02:26:35.169 App[27290:70b] 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:0x8b43490 V:[UIButton:0x8b43370(44)]>",
"<NSLayoutConstraint:0x8b413e0 V:|-(0)-[UITableView:0xe1f0200] (Names: '|':UIView:0x8b46430 )>",
"<NSLayoutConstraint:0x8b41410 V:[UIButton:0x8b43370]-(0)-| (Names: '|':UIView:0x8b46430 )>",
"<NSLayoutConstraint:0x8b41470 V:[UITableView:0xe1f0200]-(0)-[UIButton:0x8b43370]>",
"<NSLayoutConstraint:0x8b41680 V:|-(220)-[UIView:0x8b46430] (Names: '|':UIView:0x8b463a0 )>",
"<NSLayoutConstraint:0x8b444a0 V:[UIView:0x8b46430]-(404)-| (Names: '|':UIView:0x8b463a0 )>",
"<NSLayoutConstraint:0x8b445d0 V:[UIView:0x8b463a0]-(0)-| (Names: '|':FXBlurView:0x8b460c0 )>",
"<NSLayoutConstraint:0x8b44630 V:|-(0)-[UIView:0x8b463a0] (Names: '|':FXBlurView:0x8b460c0 )>",
"<NSLayoutConstraint:0x8b44ce0 V:|-(0)-[FXBlurView:0x8b460c0] (Names: '|':UIView:0x8b448d0 )>",
"<NSLayoutConstraint:0x8b44760 V:[FXBlurView:0x8b460c0]-(0)-[_UILayoutGuide:0x8b44790]>",
"<_UILayoutSupportConstraint:0x8b46790 V:[_UILayoutGuide:0x8b44790(0)]>",
"<_UILayoutSupportConstraint:0x8b57e40 _UILayoutGuide:0x8b44790.bottom == UIView:0x8b448d0.bottom>",
"<NSAutoresizingMaskLayoutConstraint:0x8b5aed0 h=--& v=--& V:[UIView:0x8b448d0(568)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x8b43490 V:[UIButton:0x8b43370(44)]>
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.
2013-11-12 02:26:35.170 App[27290:70b] 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:0x8b41680 V:|-(220)-[UIView:0x8b46430] (Names: '|':UIView:0x8b463a0 )>",
"<NSLayoutConstraint:0x8b444a0 V:[UIView:0x8b46430]-(404)-| (Names: '|':UIView:0x8b463a0 )>",
"<NSLayoutConstraint:0x8b445d0 V:[UIView:0x8b463a0]-(0)-| (Names: '|':FXBlurView:0x8b460c0 )>",
"<NSLayoutConstraint:0x8b44630 V:|-(0)-[UIView:0x8b463a0] (Names: '|':FXBlurView:0x8b460c0 )>",
"<NSLayoutConstraint:0x8b44ce0 V:|-(0)-[FXBlurView:0x8b460c0] (Names: '|':UIView:0x8b448d0 )>",
"<NSLayoutConstraint:0x8b44760 V:[FXBlurView:0x8b460c0]-(0)-[_UILayoutGuide:0x8b44790]>",
"<_UILayoutSupportConstraint:0x8b46790 V:[_UILayoutGuide:0x8b44790(0)]>",
"<_UILayoutSupportConstraint:0x8b57e40 _UILayoutGuide:0x8b44790.bottom == UIView:0x8b448d0.bottom>",
"<NSAutoresizingMaskLayoutConstraint:0x8b5aed0 h=--& v=--& V:[UIView:0x8b448d0(568)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x8b444a0 V:[UIView:0x8b46430]-(404)-| (Names: '|':UIView:0x8b463a0 )>
Break on objc_exception_throw to catch this in the debugger.
我如何理解导致警告/错误的问题是什么?
我在哪里可以学习如何“阅读”这些警告?
我的意思是例如V:[UIView:0x8b46430]-(404)-|
的含义是什么。
答案 0 :(得分:1)
N:[UIView的:0x8b46430] - (404) - |
该行转换为:UIView距离它的超级视图底部404pt(在其超级视图内)
NSLayoutConstraint:0x8b41680 V:| - (220) - [UIView:0x8b46430](名称:'|':UIView:0x8b463a0) NSLayoutConstraint:0x8b444a0 V:[UIView:0x8b46430] - (404) - | (名称:'|':UIView:0x8b463a0) NSLayoutConstraint:0x8b445d0 V:[UIView:0x8b463a0] - (0) - | (名称:'|':FXBlurView:0x8b460c0)
视图0x8b46430与容器UIView的关系为404pt:0x8b463a0,同时将约束设置为0pt到容器FXBlurView:0x8b460c0。
答案 1 :(得分:0)
找到解决方案。 问题在于您编辑约束的顺序 MATTERS !
这两个相互矛盾的限制是:
"<NSLayoutConstraint:0x8b41680 V:|-(220)-[UIView:0x8b46430] (Names: '|':UIView:0x8b463a0 )>",
"<NSLayoutConstraint:0x8b444a0 V:[UIView:0x8b46430]-(404)-| (Names: '|':UIView:0x8b463a0 )>",
这个UIView
的超级视图的顶部空间边距为220 pt,底部空间边距为404 pt,这是错误的,因为它超过了主视图高度(568 pt高)。
错误的代码就是这个:
self.myViewTopMarginCon.constant = $value;
self.myViewBottomMarginCon.constant = $value;
正确的是:
self.myViewBottomMarginCon.constant = $value;
self.myViewTopMarginCon.constant = $value;