Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Implementing Constraints

JS Park
JS Park
15,959 Points

Conflicting Constraints

When I add the bottom constraint that is 50 px from the bottom, it doesn't turn all blue like in the video.

I get an error about conflicting constraints with the conflicting constraints being: View.bottom = bottomMargin + 50 bottom = View.bottom

2 Answers

Adim Ofunne
Adim Ofunne
14,736 Points

I ran into the same issue. I resolved it doing the following

  1. Undo the last constraint
  2. Look for the document outline (the panel on the left with "View Controller Scene")
  3. Under "view controller" You see an object called "Stack view"
  4. Select "Stack view"
  5. Set the constraint on "Stack View" that we see in the video

issue is resolved

EDIT: After looking more into this, I think the issue comes from the fact that Apple added stack view which is a new construct (Which this video does not take into account).

The problem comes from the fact that when you add constraints using the constraint toolbar it auto chooses the closest super view which is the "Stack View" (in new Xcode) so you can solve this by adding the constraint to "Stack View" like I recommended above or you can do the click and drag to the "Super View". This specifies which view your constraint is referring to, which will be the Super view because you specified with the drag.

In your document outline inside the storyboard their should be a right facing arrow next to the scene in question. Click it and it will take you to your constraint suggestions.

Here is a image to help you find the document outline. Notice the right facing red arrow at the top of the panel. If you need further help let me know. https://25lesn1e1hrr2pqoyr3zynlm-wpengine.netdna-ssl.com/wp-content/uploads/2014/12/pic-twelve-600x338@2x.png

I cannot see all of your constraints but the bottom constraint if you double click it and go to its detail view should be:

  1. First Item: Safe Area.Bottom
  2. Relation: Equal
  3. Second Item: View.Bottom
  4. Constant: 50

You can check this yourself the next time you have this problem by just downloading the Project File under Downloads of the video. The project will be completed through the end of the video for you.

If this helped you out please remember to mark it as best answer and give it an upvote. Greatly appreciated.