Typo in Fig 3.24? Or did I miss a step?


#1

Hi, when following the directions regarding Figure 3.24, after I add these constraints from Fig 3.24 (after having created the other constraint on the top label), the frames are updatedand my second label moves to the top, underneath the 212 label. I am either doing something wrong or there is a typo, or …?


#2

I closed down Xcode and started it up again today, and re-added the constraints, and it works fine now. Possibly user error, though there really wasn’t anything complicated in the instructions…


#3

Same issue is happening to me. Opening/closing doesn’t seem to fix it :frowning:

I’ll keep working at it - I must be doing something wrong.


#4

Seems like the issue for me had to do with each UILabel not being the same distance apart before I applied the strut constraint. Once I spaced them out evenly, I was able to apply the constraints with no problem.


#5

I was having the exact same issue.

What I did to address it:

  1. Start with the 212 label having a horizontal in container constraint. The book says to remove this constraint, but I think you need it as a baseline. Something has to be defined relative to the superview, right?

  2. Make sure that none of the frames are overlapping. It seems if the frames are overlapping, even if the text looks nicely spaced, IB assumes that the nearest neighbor is the next nearest from how things appear. Does that make sense?

  3. Once that is done, you can configure the constraints as the book advises.


#6

Had exactly the same issue on my first couple tries. Moving labels around and repeating constrains steps seems to work eventually. Very confused about this bit.


#7

Yeah I just ran into this problem. The problem is that the frame are overlapping which is causing a miscalculation for the nearest neighbor.

Create a good amount of vertical spacing between your frames and then redo the constraints. That should solve the problem. Shout out to @bthooper, his previous reply helped.


#8

Terrific, thanks everyone. After spacing my labels out a little more, the overlapping problem was also fixed for me!


#9

Awesome! Thanks everybody! I wanted to point out this also helped me move on when I was stuck trying to figure out how to “Make sure that Update Frames has None selected.” This is no longer an option in Xcode 8.3.3. Spacing did it for me as well.


#10

Thank you for your explanation!


#11

I’m using Xcode 9.4 and ran into same issue. @roylt84 advice solved my issue. When I added additional vertical spacing, the problem went away.