Xcode4 Xcode 4.4约束错误
我正在使用Xcode 4.4并在interface builder中创建视图。当我运行我的应用程序时,我始终会遇到以下约束错误Xcode4 Xcode 4.4约束错误,xcode4,constraints,Xcode4,Constraints,我正在使用Xcode 4.4并在interface builder中创建视图。当我运行我的应用程序时,我始终会遇到以下约束错误 Unable to simultaneously satisfy constraints: ( "<NSAutoresizingMaskLayoutConstraint:0x104486db0 h=-&- v=-&- V:[NSView:0x106a33090]-(0)-| (Names: '|':NSClipView:0x106a0c
Unable to simultaneously satisfy constraints:
(
"<NSAutoresizingMaskLayoutConstraint:0x104486db0 h=-&- v=-&- V:[NSView:0x106a33090]-(0)-| (Names: '|':NSClipView:0x106a0cef0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x104486e10 h=-&- v=-&- V:|-(15)-[NSView:0x106a33090] (Names: '|':NSClipView:0x106a0cef0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x1002da350 h=--& v=--& V:[NSClipView:0x106a0cef0(672)]>",
"<NSLayoutConstraint:0x106a11ba0 V:[NSView:0x1044eb990]-(657)-| (Names: '|':NSView:0x106a33090 )>",
"<NSLayoutConstraint:0x1044d68d0 V:|-(270)-[NSView:0x1044eb990] (Names: '|':NSView:0x106a33090 )>",
"<NSLayoutConstraint:0x100271040 V:[NSView:0x1044eb990(245)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x100271040 V:[NSView:0x1044eb990(245)]>
Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints
to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens.
And/or, break on objc_exception_throw to catch this in the debugger.
无法同时满足约束:
(
"",
"",
"",
"",
"",
""
)
将尝试通过打破约束进行恢复
设置NSUserDefault NSCONSTRAINTBASEDLAYOUT可视化mutuallyExclusiveConstraints
若为“是”,则在发生这种情况时自动调用-[NSWindow VisualizationConstraints:]。
和/或,在objc_异常_抛出时中断,以便在调试器中捕获该异常。
关于如何解决这个问题,有什么建议吗
感谢您对约束的每一个视图,请执行以下操作:
[view setTranslatesAutoresizingMaskIntoConstraints:NO];
这将消除日志中的“NSAutoresizingMaskLayoutConstraint”部分。还有一种方法可以解决此问题,而无需编写代码 在情节提要中,选择超级视图。在属性检查器中,取消选中“自动调整子视图大小”复选框,如下所示 这将向情节提要XML文件添加
autoresizesSubviews=“NO”
。在我的例子中,XML已经包含了translatesAutoresizingMaskIntoConstraints=“NO”
,但是,这并没有阻止autolayout创建NSAutoresizingMaskLayoutConstraint
s
注意:也许我的答案只适用于Xcode 5,因为我无法检查Xcode 4.4是否已经有这个复选框。但由于谷歌在搜索NSAutoresizingMaskLayoutConstraint
时仍然会提出这个问题,这可能会让某些人受益