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!
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
lvwdhydynw
6,443 PointsIndividual layout per device
Hello everyone
So I have finished "Build a Simple iPhone App with Swift 3" course and I wanted to play a bit. I decided to make a slightly different version of "Fun Fact" app. I have now just one label, but six different buttons (each one represents a different group of facts - historical facts, political facts etc). The problem is that even if I do my best, 4.7 inch devices are the last ones where the layout isn't broken. I just can't make it work for smaller devices (and even on 4.7 inch devices it's so close it doesn't look good.
So I want to ask - is it possible to (make an auto layout and then) adjust layout depending on device/device screen size?
1 Answer

eberhapa
51,495 PointsWell, this is an interesting topic and there are some videos for this at treehouse. To differentiate between different devices the keyword is "size classes". Some links down below:
- https://makeapppie.com/2016/09/05/an-introduction-to-size-classes-for-xcode-8/
- https://medium.com/@craiggrummitt/size-classes-in-interface-builder-in-xcode-8-74f20a541195
- https://teamtreehouse.com/library/whats-new-in-auto-layout-in-ios-9
- https://teamtreehouse.com/library/introduction-to-auto-layout-in-ios
You will also find tones of videos and explanations on youtube.
An other possibility if you have not enough space for placing your buttons is using a static UITableView or a UIScrollView but it always depends on what you exactly want to do.
- https://teamtreehouse.com/library/introduction-to-scroll-views-with-swift-2
- https://teamtreehouse.com/library/introduction-to-table-views
I recommend going trough all videos related to swift on treehouse to get familiar with all possibilities and afterwords start creating your own stuff and playing around because you will get familiar with different keywords and it will be easier for you to search on the internet. Stackoverflow is also always a good point to search :)
Hope i could help you a little bit.
Best, Patrick
lvwdhydynw
6,443 Pointslvwdhydynw
6,443 PointsSorry for late answer and thank you for help! :)
Cheers, Johnny