From the course: iOS Development Tips

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Lay out iPad landscape and multitasking apps

Lay out iPad landscape and multitasking apps

From the course: iOS Development Tips

Lay out iPad landscape and multitasking apps

- [Instructor] If there's one thing in autolayout that drive me nuts, it's laying out for landscape, different than portrait, on an iPad. Phones are easy, since the class sizes are different for portrait and landscape. For all phones, if I have a compact type, I know I'm in landscape, but iPads are regular width, regular height, so I have no clue when to programmatically change the layout. Let's look at one way to handle this. Download the example file. Take a loot at the storyboard. I've a large number of buttons and an image. I want landscape, the buttons to the side, while in portrait, I want the buttons below, like I have, here. I set this up with a nested stack view, so by switching between vertical and horizontal axes, I can set this layout appropriately. Head over to the view controller code. What I'm going to do is look at the device rotation and decide what orientation I should be in. I need to generate orientation notifications. Go to the bottom of the code, and you will see…

Contents