0

我正在以编程方式移动一些视图来改变其约束,并且在某些时候我得到了这个:

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)-|

4

2 回答 2

1

V:[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:0x8b463a0 具有 404pt 关系,同时对容器 FXBlurView:0x8b460c0 具有相同的约束设置为 0pt。

于 2013-11-12T01:39:34.813 回答
0

Found the solution. The problem was that the order in which you edit the constraints MATTERS!

The two conflicting constraints were these:

"<NSLayoutConstraint:0x8b41680 V:|-(220)-[UIView:0x8b46430]   (Names: '|':UIView:0x8b463a0 )>",
"<NSLayoutConstraint:0x8b444a0 V:[UIView:0x8b46430]-(404)-|   (Names: '|':UIView:0x8b463a0 )>",

This UIView have a top space margin from its superview of 220 pt and a bottom space margin of 404 pt which is wrong because it's more than the main view height (which is 568 pt tall).

The wrong code was this one:

self.myViewTopMarginCon.constant = $value;
self.myViewBottomMarginCon.constant = $value;

The correct one is this:

self.myViewBottomMarginCon.constant = $value;
self.myViewTopMarginCon.constant = $value;
于 2013-11-12T01:57:42.977 回答