Search code examples
swiftxcodeautolayoutstackview

Having troubles with Auto layout - why do I get errors for adding a label under a stack view?


I am currently working through the 'App development with swift' book and am trying to do the 'Apple pie' project. I have been following directions and after doing (What I think) are the same things the book tells me to do, I am getting errors. So I'm hoping someone can explain to me why the errors below are appearing.

Project before adding label to bottom of vertical stack view:

Project before adding label to bottom of vertical stack view

Project after adding label to bottom of vertical stack view:

Project after adding label to bottom of vertical stack view

Errors received:

Errors received


Solution

  • Try setting the height on the label to 60 and that Alignment 'Centre' is selected in the attributes inspector.

    Also make sure the parent StackView is on Alignment: Fill, Distribution: Fill.