0
votes

I've made good progress with the FoodTracker example in Start Developing iOS Apps (Swift), but hit a snag in the Implement a Custom Control:

2017-02-05 18:45:01.644693 FoodTracker[3066:188362] [LayoutConstraints] 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. ( "", "", "", "" )

Will attempt to recover by breaking constraint (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful. 2017-02-05 18:45:01.645167 FoodTracker[3066:188362] [LayoutConstraints] 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. ( "", " (active)>", "", "" )

Will attempt to recover by breaking constraint (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in may also be helpful.

Instead of a single red square 44px x 44px in size, the entire Horizontal View is red.

I've gone through the steps multiple times, copied and pasted the code examples, but I'm getting the same error each time.

I'm using Xcode 8.2.1 on OS X El Capitan 10.11.6

3
The description the error shows you can be quite helpful, I noticed something right away "Unable to simultaneously satisfy constraints" - This usually means that you're trying to anchor a constraint in a fashion that's impossible. Please show your layout code so we can help figure out the problem - Pierce
Also, post the full layout warning/error. They tend to point directly at the issue. (Yes, it's very ugly, but that's the nature of this.) - dfd
@Pierce, the are no instructions in the guide about constraints, and since I'm new to this, I don't understand what to do. Also, the code I've used is in Add Buttons to the View. - Wayne Smallman
The error description says "Unable to simultaneously satisfy constraints". This usually means that you've created two or more constraints that can't exist at the same point (for example, you set up a "width" constraint for a control, and set up the width to equal to superview's width - that's actually what happened to me, when I first got this error). - michalronin
@dfd, where would I find these additional warnings or errors? - Wayne Smallman

3 Answers

1
votes

The Horizontal Stack View needs to be WITHIN the other Stack View. I was able to reproduce this problem by having the Horizontal Stack View separate (& below) the other Stack View. I was able to resolve the problem by dragging the Horizontal Stack View (Rating Control) so that it was inside the other Stack View.

0
votes

Reset the constraints in the Storyboard (by clicking on "Resolve layout issues" in the bottom right corner) and re-add them again, this should clear any conflicting restraints in the Storyboard which will fix the error

0
votes

In your storyboard, use the Object library to find a Horizontal Stack View object, and drag one into your storyboard scene so that it’s in the stack view below the image view.

Underneath is an image of the Horizontal Stack View object which I read as placing it beneath Photo Image View object on the Storyboard itself.

As I said, I am new to this!

Guys, thank you for helping out.