1

I get this error:

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:0x1600aec0 V:[UIView:0x102021d0]-(0)-|   (Names:    '|':UIView:0x1600a980 )>",
 "<NSLayoutConstraint:0x1600ae80 V:|-(494)-[UIView:0x102021d0]   (Names: '|':UIView:0x1600a980 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1600e8a0 h=-&- v=-&- UIView:0x1600a980.height == UIWindow:0x9e0ea30.height>",
"<NSAutoresizingMaskLayoutConstraint:0x9e2d130 h=--- v=--- V:[UIWindow:0x9e0ea30(480)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x1600aec0 V:[UIView:0x102021d0]-(0)-|   (Names: '|':UIView:0x1600a980    )>

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.

the view that generates this error has 4 constrains for left/right/top/bottom and I can not delete any of them.

I have tried:

[View setTranslatesAutoresizingMaskIntoConstraints:NO];

with no result.

do you have any idea how to fix this?

Thank you!

4

2 回答 2

4

问题在于垂直布局。

<NSAutoresizingMaskLayoutConstraint:0x9e2d130 h=--- v=--- V:[UIWindow:0x9e0ea30(480)]>

自动调整窗口的蒙版。固定边距和大小。你无法改变这一点。

<NSAutoresizingMaskLayoutConstraint:0x1600e8a0 h=-&- v=-&- UIView:0x1600a980.height == UIWindow:0x9e0ea30.height>

自动调整掩码(固定边距,可调整大小的内容)。可能是您的控制器的视图。高度是480(设置为等于窗口的大小)。这里没有什么可修复的。

<NSLayoutConstraint:0x1600aec0 V:[UIView:0x102021d0]-(0)-|   (Names:    '|':UIView:0x1600a980 )>
<NSLayoutConstraint:0x1600ae80 V:|-(494)-[UIView:0x102021d0]   (Names: '|':UIView:0x1600a980 )>

您会注意到,两个约束都在使用相同的视图 ( ) 做某事,[UIView:0x102021d0]并且具有相同的第二个视图作为参数 ( UIView:0x1600a980)。第二个视图是我们控制器的视图。

这两个约束定义了与第二个视图边缘的距离。第一个定义底部 ( 0)。第二个定义顶部(494)。如果超级视图的大小为480,则意味着[UIView:0x102021d0]高度等于-14触发该异常的高度。

如何解决?好吧,将494约束更改为正确的值。您甚至可能不想要“顶部”约束,也许您想要一个固定的高度。

问题是如何产生的?您可能为 iPhone 5 创建了约束,然后尝试使用 iPhone 4 运行该应用程序。如果将 xib 中的模拟大小更改为 iPhone 4,您应该会立即看到问题。

于 2013-07-25T09:30:57.447 回答
0

There are still views that have translatesAutoresizingMaskIntoConstraints set to YES, apparently, otherwise you wouldn't be getting that message. It's probably the superview of the view that's giving you problems. Make sure that it also doesn't translate its autoresizing masks to constraints.

于 2013-07-25T09:10:20.517 回答