Size classes

So now we've built out all of our views in our storyboard, connected them with segues, and set constraints using Auto Layout, and everything is perfect! Or… is it? If you've tried to rotate your phone into landscape, you may have noticed that everything is decidedly not perfect. Our constraints don't hold up particularly well when the screen becomes so wide and short.

But what should we do? It would be nearly impossible to come up with a set of constraints that are so robust that they work in all sizes and orientations that a device can come in. Luckily, there is one last feature that solves this very problem: size classes.

Size classes are a way to group constraints into categories that are general enough that you don't have to design ...

Get Learning Xcode 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.