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 Build a Simple iPhone App with Swift Improving Our User Interface Implementing Auto Layout

Hilary Couture
Hilary Couture
11,755 Points

Despite looking correct in Interface Builder, when run in the simulator, everything is off-center.

Despite having followed all instructions in the video and looking correct in Interface Builder, when I run the app in the simulator, everything is slightly off-center (towards the left). I can't figure out why this is despite troubleshooting. Any ideas or suggestions as to why would be super helpful!

4 Answers

Walter Somerville
Walter Somerville
20,698 Points

Without seeing your project I can't be 100% sure, but I would guess that you are either missing some auto layout constraints, or that the constraints you have are not properly implemented. Have you set any sort of alignment constraints in your storyboard?

If not, apple's docs are a good place to get started with auto layout.

Hope that helps!

I had the same problem this "might" be due to the simulator selected as iphone 6 or 6+ or you simply have the constraints set up wrong!

Ben Manson
Ben Manson
5,882 Points

I was having the same problem. The easy way to fix it is just to set additional horizontal constraints for the label and the button (set constraints for the right side of the buttons/labels).

Christian Dangaard
Christian Dangaard
3,378 Points

A bit late but this really bugged me despite following the video. I looked closer during the video after multiple playbacks and found that in the video, the teacher had Leading Margin Space set to 36, while for my version of Xcode it was set to 32 (I had not made any modifications prior). I set this back to 36 and the elements in the page became centered again.