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 Positioning and Size

alexis dionne-bouchard
alexis dionne-bouchard
1,971 Points

Auto layout fails

First, with my version of Xcode (8.1) I cannot seem to use an iPhone 6s display so maybe this is why I'm getting an error? When I select iPhone 6s from my device list, the display remains as an iPhone 7.

That being said, the error I'm getting with this exercise is that when I go and try to fix ambiguities with auto layout by updating frames, instead of placing it perfectly in center and evening the text out, it spreads it beyond the width of the view and the FunFactLabel becomes half hidden and unreadable again. Any clues on why this is happening?

Thank you, Alex

Raed Alahmari
Raed Alahmari
12,966 Points

Make sure you have the "trailing constraints , leading constraints and vertically centered " added to the label

While I am not getting any kind of errors, I have noticed the exact same "issue" that you mentioned about the display being only iPhone 7 that you brought up in the first part of your question. I have the simulator set to iPhone 6s, just like Pasan Premaratne does in his video, but down at the bottom of the Main.storyboard it says iPhone 7.

I have tried to figure out a way to change it down there, including changing the simulator, but nothing has made it change. I have done a short search on Google, but since I am still new to Xcode, I guess I am not wording my searches the correct way as I am not able to find any kind of answer that relates to what I am trying to do.

Thankfully, though, so far I am not getting any kind of errors and am able to follow along with the courses without a hitch. Hopefully, someone will see this eventually and give some insight as to why the issue you and I are both seeing is revealing itself the way it is, and I hope someone can answer your question on the errors you are getting.

The only thing that I can think to suggest is possibly to update your version of Xcode, even though it is only a "minor" update.

1 Answer

Pasan Premaratne
STAFF
Pasan Premaratne
Treehouse Teacher

Hey everyone here. Xcode has changed since this course was recorded so we might need to update the relevant videos. To change the storyboard scene look at the bottom of the window where it says "View as: iPhone 7 (wC hR)".

Click there and you can switch between device sizes.

You should know though that you can't change the storyboard to represent a 6S, because a 6S and 7 have absolutely no difference when it comes to screen size. Designing on a 7 layout and displaying it on a 6S simulator should look the same