1

我的 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% 高度的集合视图。

自动布局让我发疯,知道吗?

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

IB 约束

4

1 回答 1

1

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

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

由于它是由 IB 添加的,因此您无法删除它,因此为了忽略它,我将其优先级设置为 1。

IB优先

于 2013-06-03T13:07:18.283 回答