iOS,动画视图的约束导致错误"无法同时满足约束"

时间:2015-05-03 18:20:52

标签: ios objective-c

我正在尝试为容器视图的一个约束设置动画。在IB中,视图受到限制,没有错误或警告。当我在viewDidLoad中调用这些方法时,要更改视图y坐标,如下所示:

 self.queueContainerYConst.constant += 550;
    [self.view layoutIfNeeded];

我收到消息"无法满足约束..."。在运行应用程序时,我的动画和用户界面看起来很好,所有内容似乎都受到了适当的限制。这是我在控制台中收到的整个消息。

2015-05-03 14:17:52.668 Streamacy[15914:3333195] 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:0x155a95c0 V:|-(614)-[UIView:0x155a83a0]   (Names: '|':UIView:0x155a91b0 )>",
    "<NSLayoutConstraint:0x155a95f0 V:[UIView:0x155a83a0]-(0)-|   (Names: '|':UIView:0x155a91b0 )>",
    "<NSLayoutConstraint:0x155af080 'UIView-Encapsulated-Layout-Height' V:[UIView:0x155a91b0(568)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x155a95f0 V:[UIView:0x155a83a0]-(0)-|   (Names: '|':UIView:0x155a91b0 )>

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.
2015-05-03 14:17:52.684 Streamacy[15914:3333195] 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:0x1566a2a0 UIView:0x156a1900.width == UIView:0x156a1900.height>",
    "<NSLayoutConstraint:0x156a9000 V:[UIView:0x156a1900]-(32)-[UIProgressView:0x15688f30]>",
    "<NSLayoutConstraint:0x156a0df0 V:[UIProgressView:0x15688f30]-(11)-[MarqueeLabel:0x156a7360'Awake']>",
    "<NSLayoutConstraint:0x156a0eb0 UIView:0x1569dd90.trailingMargin == UIView:0x156a1900.trailing + 99>",
    "<NSLayoutConstraint:0x156a0f10 UIView:0x156a1900.leading == UIView:0x1569dd90.leadingMargin + 99>",
    "<NSLayoutConstraint:0x156a0f40 UIView:0x156a1900.top == UIView:0x1569dd90.topMargin - 46>",
    "<NSLayoutConstraint:0x156a92f0 V:[UILabel:0x156a6ea0'Tycho']-(17)-[UITableView:0x1587a000]>",
    "<NSLayoutConstraint:0x156a93b0 V:[MarqueeLabel:0x156a7360'Awake']-(2)-[UILabel:0x156a6ea0'Tycho']>",
    "<NSLayoutConstraint:0x156a94d0 V:[UITableView:0x1587a000]-(0)-[_UILayoutGuide:0x156a8b20]>",
    "<_UILayoutSupportConstraint:0x156a4cf0 V:[_UILayoutGuide:0x156a8b20(0)]>",
    "<_UILayoutSupportConstraint:0x156a4810 _UILayoutGuide:0x156a8b20.bottom == UIView:0x1569dd90.bottom>",
    "<NSLayoutConstraint:0x156b6070 'UIView-Encapsulated-Layout-Width' H:[UIView:0x1569dd90(320)]>",
    "<NSLayoutConstraint:0x156b60a0 'UIView-Encapsulated-Layout-Height' V:[UIView:0x1569dd90(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1566a2a0 UIView:0x156a1900.width == UIView:0x156a1900.height>

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.
2015-05-03 14:17:52.688 Streamacy[15914:3333195] 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:0x156a9000 V:[UIView:0x156a1900]-(32)-[UIProgressView:0x15688f30]>",
    "<NSLayoutConstraint:0x156a0df0 V:[UIProgressView:0x15688f30]-(11)-[MarqueeLabel:0x156a7360'Awake']>",
    "<NSLayoutConstraint:0x156a0f40 UIView:0x156a1900.top == UIView:0x1569dd90.topMargin - 46>",
    "<NSLayoutConstraint:0x156a92f0 V:[UILabel:0x156a6ea0'Tycho']-(17)-[UITableView:0x1587a000]>",
    "<NSLayoutConstraint:0x156a93b0 V:[MarqueeLabel:0x156a7360'Awake']-(2)-[UILabel:0x156a6ea0'Tycho']>",
    "<NSLayoutConstraint:0x156a94d0 V:[UITableView:0x1587a000]-(0)-[_UILayoutGuide:0x156a8b20]>",
    "<_UILayoutSupportConstraint:0x156a4cf0 V:[_UILayoutGuide:0x156a8b20(0)]>",
    "<_UILayoutSupportConstraint:0x156a4810 _UILayoutGuide:0x156a8b20.bottom == UIView:0x1569dd90.bottom>",
    "<NSLayoutConstraint:0x156b60a0 'UIView-Encapsulated-Layout-Height' V:[UIView:0x1569dd90(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x156a9000 V:[UIView:0x156a1900]-(32)-[UIProgressView:0x15688f30]>

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.

看来容器视图中的所有内容都放错了,为什么?我不正确地动画/改变我的观点吗?

1 个答案:

答案 0 :(得分:0)

你的观点过于拘束。您的超级视图的顶部和底部的约束为614,但该视图的高度为568,因此这些数字不会相加。如果它适用于您的目的,那么只有其中一个垂直约束和固定高度才会更好(如果您根据不同的屏幕尺寸进行调整,可以相对于超视图的高度进行“固定”高度) 。