Unable to simultaneously satisfy constraints – No constraints in place

I have gone through and removed every single user constraint yet I am still getting the following error ONLY after I rotate the device. I have absolutely no clue why though. Does anyone have any ideas?

2013-01-14 21:30:31.363 myApp[35869:c07] 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) 
    "<NSAutoresizingMaskLayoutConstraint:0x84543d0 h=--& v=--& V:[UIView:0xa330270(768)]>",
    "<NSLayoutConstraint:0xa338350 V:[UIView:0xa331260]-(-1)-|   (Names: '|':UIView:0xa330270 )>",
    "<NSLayoutConstraint:0xa338390 V:|-(841)-[UIView:0xa331260]   (Names: '|':UIView:0xa330270 )>"

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0xa338350 V:[UIView:0xa331260]-(-1)-|   (Names: '|':UIView:0xa330270 )>

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.

  • Why calling setNeedsUpdateConstraints isn't needed for constraint changes or animations?
  • Xcode auto layout constraints - why defaulting to negative padding?
  • “The constraint outlet from the TableViewController to the NSLayoutConstraint is invalid.” error
  • Update the constant property of a constraint programmatically in Swift?
  • Building a titleView programmatically with constraints (or generally constructing a view with constraints)
  • Width and Height Equal to its superView using autolayout programmatically?
  • 7 Solutions Collect From Internet About “Unable to simultaneously satisfy constraints – No constraints in place”

    Let’s look at these one by one.

    "<NSAutoresizingMaskLayoutConstraint:0x84543d0 h=--& v=--& V:[UIView:0xa330270(768)]>"

    This is saying view 0xa330270 (A) must be 768 points high.

    "<NSLayoutConstraint:0xa338350 V:[UIView:0xa331260]-(-1)-| (Names: '|':UIView:0xa330270 )>"

    This is saying view 0xa331260 (B)’s bottom edge must be a gap of -1 from the bottom of A, which is it’s superview.

    "<NSLayoutConstraint:0xa338390 V:|-(841)-[UIView:0xa331260] (Names: '|':UIView:0xa330270 )>"

    This is saying that B‘s top edge must be a gap of 841 points from the top of its superview, A.

    These three things can’t all be true – A can’t be 768 points high, and contain a subview with a top edge 841 points inset from the top and -1 points inset from the bottom. Where have you defined each of these constraints?

    You haven’t said what layout you are trying to achieve, but it looks like you might have an autoresizing mask on the superview that is preventing it changing in height when you rotate the device. As far as I know the autoresizing constraints only appear if you have added views programmatically, since a storyboard or xib is either all-autolayout, or not. Unless you are doing something like adding an auto laid out view (loaded from a nib?) to another view from a non-autolayout nib?

    I guess this is not a common error, but I solved it somewhat in a layman way. I was getting cryptic messages like the one above. To make sense of it, I created dummy view classes and attached it to the views in my storyboard. For example, if I had a UIView, I created a class called AddressView and attached it to this view in story board. Its a bit time consuming, but it worked for me. After that instead of object-ids, I got class names which helped me zero in on the views that were causing the issue very easily. My error message now read,

    2013-07-02 04:16:20.434 Myproject [2908:c07] 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:0x9edeae0 V:|-(0)-[AddressView:0x143ee020]   (Names: '|':MainView:0x129eb6a0 )>",
        "<NSAutoresizingMaskLayoutConstraint:0x11e998c0 h=--& v=--& V:[MainView:0x129eb6a0(704)]>",
        "<NSLayoutConstraint:0x156720b0 V:[AddressView:0x143ee020]-(896)-|   (Names: '|':MainView:0x129eb6a0 )>"

    Here you can see, the names of my views MainView and Address view are causing the issue.

    To resolve it, I just moved my subview (in this case Address view) and repositioned it back. I think the issue began as I was using a mix of new Automatic Layour in Xcode 4.5 and old skills or manually positioning the views.

    Anyways, not sure if it was more luck than diligence, but nevertheless this could be a different way of debugging. Maybe this helps someone!

    thanks to http://useYourLoaf.com for this complete solution:


    A quick tip I found buried in a WWDC 2015 session on Auto Layout that helps when debugging problems with constraints

    If you have used Auto Layout you will be familiar with the log that Xcode spits out when you get something wrong. To create an example I modified my Stack View sample code and added a constraint to each of the images to give them a fixed width of 240 (not a good idea as we will see).

    enter image description here

    That works in regular width views such as the iPad but is too wide for a compact width view such as the iPhone in portrait. The console log at runtime is not fun to read. Skipping the boilerplate text you get a list of the problematic constraints:

    "<NSLayoutConstraint:0x7fc1ab520360 H:[UIImageView:0x7fc1ab532650(240)]>",
    "<NSLayoutConstraint:0x7fc1ab536ef0 H:[UIImageView:0x7fc1ab537380(240)]>",
    "<NSLayoutConstraint:0x7fc1ab545cc0 UIView:0x7fc1ab53d870.trailingMargin == UIStackView:0x7fc1ab53dae0.trailing>",
    "<NSLayoutConstraint:0x7fc1ab545d10 UIStackView:0x7fc1ab53dae0.leading == UIView:0x7fc1ab53d870.leadingMargin>",
    "<NSLayoutConstraint:0x7fc1ab54e240 'UISV-alignment' UIStackView:0x7fc1ab53dc70.centerX == UIStackView:0x7fc1ab531a10.centerX>",
    "<NSLayoutConstraint:0x7fc1ab5167c0 'UISV-canvas-connection' UIStackView:0x7fc1ab531a10.leading == UIImageView:0x7fc1ab532650.leading>",
    "<NSLayoutConstraint:0x7fc1ab54ad80 'UISV-canvas-connection' H:[UIImageView:0x7fc1ab537380]-(0)-|   (Names: '|':UIStackView:0x7fc1ab531a10 )>",
    "<NSLayoutConstraint:0x7fc1ab5397d0 'UISV-canvas-connection' UIStackView:0x7fc1ab53dae0.leading == _UILayoutSpacer:0x7fc1ab54c3c0'UISV-alignment-spanner'.leading>",
    "<NSLayoutConstraint:0x7fc1ab54a4a0 'UISV-canvas-connection' UIStackView:0x7fc1ab53dae0.centerX == UIStackView:0x7fc1ab53dc70.centerX>",
    "<NSLayoutConstraint:0x7fc1ab54b110 'UISV-spacing' H:[UIImageView:0x7fc1ab532650]-(16)-[UIImageView:0x7fc1ab537380]>",
    "<NSLayoutConstraint:0x7fc1ab548210 'UISV-spanning-boundary' _UILayoutSpacer:0x7fc1ab54c3c0'UISV-alignment-spanner'.leading <= UIStackView:0x7fc1ab531a10.leading>",
    "<NSLayoutConstraint:0x7fc1ab551690 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7fc1ab53d870(375)]>"

    The log then tells you which of the above constraints it has decided to break:

    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7fc1ab536ef0 H:[UIImageView:0x7fc1ab537380(240)]>

    The log output uses the auto layout visual format language but it is hard to pick out my constraints from those created by the system. This is especially the case with stack views which are by design intended to create most of the constraints for you. In this trivial example I know the fixed width constraints that I just added broke things but it is hard to see that from the log and the more complex the view the harder it gets.

    Adding an Identifier to a Constraint

    The log gets a lot easier to understand if you add an identifier to each constraint (NSLayoutConstraint has had an identifier property since iOS 7). In Interface Builder find the constraint and add the identifier in the Attributes inspector (I am using $ as a prefix/suffix to make them stand out in the log):

    enter image description here

    Update 18-August-2015: As pointed out in the comments the identifier can only be edited in Interface Builder starting with Xcode 7. It is not visible in Xcode 6.4.

    If adding the constraint in code:

    constraint.identifier = "$HeartImageFixedWidth$"

    It is trickier if you are using the visual format language which uses arrays of constraints. For example, consider the Swift code fragment to create a fixed width constraint for the heart image view:

    let heartWidth = NSLayoutConstraint.constraintsWithVisualFormat("[heart(240)]", 
                     options:[], metrics:nil, views:viewsDictionary)

    Since heartWidth is an array of type [NSLayoutConstraint] setting the identifier is a little more work:

    for constraint in heartWidth {
      constraint.identifier = "$HeartImageFixedWidth$"

    With identifies set for my constraints it is now much easier to find them in the log file (see the first four lines):

    "<NSLayoutConstraint:0x7f92a305aeb0 '$ContainerStackViewLeading$' UIStackView:0x7f92a3053220.leading == UIView:0x7f92a3052fb0.leadingMargin + 32>",
    "<NSLayoutConstraint:0x7f92a305b340 '$ContainerStackViewTrailing$' UIView:0x7f92a3052fb0.trailingMargin == UIStackView:0x7f92a3053220.trailing + 32>",
    "<NSLayoutConstraint:0x7f92a301cf20 '$HeartImageFixedWidth$' H:[UIImageView:0x7f92a3047ef0(240)]>",
    "<NSLayoutConstraint:0x7f92a3009be0 '$StarImageFixedWidth$' H:[UIImageView:0x7f92a304d190(240)]>",
    "<NSLayoutConstraint:0x7f92a3060cc0 'UISV-alignment' UIStackView:0x7f92a30533b0.centerX == UIStackView:0x7f92a30472b0.centerX>",
    "<NSLayoutConstraint:0x7f92a301c590 'UISV-canvas-connection' UIStackView:0x7f92a30472b0.leading == UIImageView:0x7f92a3047ef0.leading>",
    "<NSLayoutConstraint:0x7f92a305f680 'UISV-canvas-connection' H:[UIImageView:0x7f92a304d190]-(0)-|   (Names: '|':UIStackView:0x7f92a30472b0 )>",
    "<NSLayoutConstraint:0x7f92a3064190 'UISV-canvas-connection' UIStackView:0x7f92a3053220.leading == _UILayoutSpacer:0x7f92a30608a0'UISV-alignment-spanner'.leading>",
    "<NSLayoutConstraint:0x7f92a30415d0 'UISV-canvas-connection' UIStackView:0x7f92a3053220.centerX == UIStackView:0x7f92a30533b0.centerX>",
    "<NSLayoutConstraint:0x7f92a305fa10 'UISV-spacing' H:[UIImageView:0x7f92a3047ef0]-(16)-[UIImageView:0x7f92a304d190]>",
    "<NSLayoutConstraint:0x7f92a30508c0 'UISV-spanning-boundary' _UILayoutSpacer:0x7f92a30608a0'UISV-alignment-spanner'.leading <= UIStackView:0x7f92a30472b0.leading>",
    "<NSLayoutConstraint:0x7f92a3063240 'UIView-Encapsulated-Layout-Width' H:[UIView:0x7f92a3052fb0(375)]>"

    It also much clearer which of the constraints the system has chosen to break:

    Will attempt to recover by breaking constraint 
    <NSLayoutConstraint:0x7f92a3009be0 '$StarImageFixedWidth$' H:[UIImageView:0x7f92a304d190(240)]>

    Adding identifiers to constraints is not without effort but it can pay off the next time you have to sort through the debug log of a complex layout.

    Further Reading

    • WWDC 2015 Session 219 Mysteries of Auto Layout, Part 2

    YourConstraintView.translatesAutoresizingMaskIntoConstraints = NO;

    Did it for me.

    I’ve fixed this problem be deleting all translatesAutoresizingMaskIntoConstraints properties from xib file (Open xib as a source code).

    One note. You get this error in logs if you are testing using a personal hotspot connection, and the hotspot status bar is at the top. It throws off the constraints.

    Hope this helps someone.. was driving me nuts.

    Its worth knowing the basics, and understand what Apple/Xcode is trying to tell you through the logs

    H = Horizontal constraint(for leading and Trailing)
    V = Vertical constraint(top and bottom edge)
    h = height
    w = width
    TopEdge    -> V:|-(points)-[VIEW:memoryAddress] 
    BottomEdge -> V:[VIEW:memoryAddress]-(points)-|
    Leading    -> H:|-(points)-[VIEW:memoryAddress] 
    Trailing   -> H:[VIEW:memoryAddress] -(points)-|
    height     -> h= --& v=--& V:[VIEW:memoryAddress((points)] 
    width      -> VIEW:memoryAddress.width == points 
    between    -> H:[VIEW 1]-(51)-[VIEW 2] 

    Once you understand this, reading your specific error is pretty easy