Autolayout约束错误

时间:2013-06-03 11:31:07

标签: ios autolayout

我的iPad项目有自动布局限制问题,当我旋转设备时出现此错误:

2013-06-03 13:16:24.969 PDFViewer[7534:907] 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:0x1f5525e0 H:[UIScrollView:0x1f551910]-(970)-|   (Names: '|':UIView:0x1f547740 )>",
    "<NSLayoutConstraint:0x1f5525a0 H:|-(0)-[UIScrollView:0x1f551910]   (Names: '|':UIView:0x1f547740 )>",
    "<NSAutoresizingMaskLayoutConstraint:0x1f562520 h=--- v=--- H:[UIWindow:0x1f543890(768)]>",
    "<NSAutoresizingMaskLayoutConstraint:0x1f560af0 h=-&- v=-&- UIView:0x1f547740.width == UIWindow:0x1f543890.width>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1f5525e0 H:[UIScrollView:0x1f551910]-(970)-|   (Names: '|':UIView:0x1f547740 )>

好吧,有些约束是有争议的,但是我没有自己设置任何约束,它们都是在Interface Builder中自动设置的,我无法删除它们。我想要的非常简单,滚动视图,固定宽度和100%高度,以及一个集合视图,剩余宽度和100%高度。

Autolayout让我发疯,不知道吗?

编辑:这是我在IB中定义的约束

IB Constraints

1 个答案:

答案 0 :(得分:0)

错误是由自动约束引起的,更准确地说是这个:

"<NSLayoutConstraint:0x1f5525e0 H:[UIScrollView:0x1f551910]-(970)-|   (Names: '|':UIView:0x1f547740 )>",

由于它被IB添加,你无法删除它,所以为了忽略它我将优先级设置为1.

IB Priority