Animating Constraints Section

Having some trouble with this section.

First, I added the two labels’ centering constraints to ViewController.swift.

Then I go to the Main.storyboard, and click the disclosure triangle next to Constraints to locate the new constraints.

But the two new constraints are not visible in this list. Does anyone know why?

Main.storyboard does not know of the constraints created in ViewController.swift. They are separate ways of creating views and constraints. If you would create that constraint in the storyboard, then it would appear in the list of constraints.

Thanks for the response @davidc. I misunderstood the book, but I get it now.

Thanks that helped me too though I had to dig a little more in order to understand.

If it helps others, you have to drag the outlet “currentQuestionLabelCenterXConstraint” to the constraint on the storyboard “Current Question Label.centerX = centerX”. Once you do that, then the outlet will be connected. You then do the same thing for the “nextQuestionLabelCenterXConstraint”.

You’re not connecting the outlet to the view directly per se; rather, you’re connecting the outlet to the already created constraints.

Hope that helps someone else and saves them from an hour+ struggling!

Thanks for your more detailed explanation, after also struggling with this.
I’m still not sure what to do.
You say ‘drag the outlet “currentQuestionLabelCenterXConstraint”’ but when I have storyboard showing, there is no mention of an outlet called currentQuestionLabelCenterXConstraint.
The diagram on page 150 shows a drag from the yellow View Controller icon above the layout, down onto the list of constraints, in which there are 10 constraints listed, whereas I have only 8. When I drag, and let go over one of the constraints, then the pop-up menu allows to choose currentQuestionLabelCenterXConstraint.
However, that name now replaces the name of the constraint in the list, so I still have only 8 constraints listed.
Have you managed to finish up with 10 constraints listed?

The missing 2 constraints are the problem. I missed creating them on page 148 - mustn’t take breaks during working time!

ha, nice! Sorry on the (overly long) delay, but glad you got it figured out. Cool. Yes, that took me a couple hours to debug for sure.