I am using Xcode 4.4 and creating my views in interface builder. When I run my app, I consistently get the following constraint errors.
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.
Any suggestions on how I can resolve this?
Thanks
For each view you're intending on constraining do this:
That will get rid of the "NSAutoresizingMaskLayoutConstraint" parts in the log.
There is also a way to solve this without writing code.
In the storyboard, select your super view. In the Attributes Inspector, deselect the "Autoresize Subviews" checkbox as shown below.
This will add
autoresizesSubviews="NO"
to the storyboard XML file. In my case, the XML already containedtranslatesAutoresizingMaskIntoConstraints="NO"
, however, this did not stop autolayout from creatingNSAutoresizingMaskLayoutConstraint
s.Note: Maybe my answer applies to Xcode 5 only, as I can't check if Xcode 4.4 already had this checkbox. But since Google still turns up this SO question when searching
NSAutoresizingMaskLayoutConstraint
, it might benefit someone.