Adding constraint causes label to "disappear"

In chapter 1, “A Simple iOS Application”, on page 15, figure 1.18, describes how to add a constraint to the first label of the application. When I do this to the first label, the label disappears from view on the simulator. If I remove the constraint, the label reappears in the simulator. If I add the vertical constraint, the label appears centered in the simulator.

Not sure what’s going on! Why does the label disappear when horizontally aligned, but reappear when vertically aligned? I would be grateful for any help on this.

My Xcode version is 14.0.1.

My apologies if this has been answered earlier.

I don’t have the book, but did you try adding both constraints?

If you have multiple labels, embed them in a Stack View and adjust its alignment
instead in the containing view.

If you have not already done so, read this: Auto Layout Guide.

Have fun :slight_smile: