Group Group Group Group Group Group Group Group Group

Adaptive Layout Tutorial in iOS 12: Getting Started | raywenderlich.com

In this tutorial, you’ll learn how to use Adaptive Layout in Xcode 10 with iOS 12, enabling you to reuse the same storyboard for multiple devices and orientations.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1343912-adaptive-layout-tutorial-in-ios-12-getting-started

I need to write an app that runs on iPad & iPhone.

The code for all the viewcontrollers and views functionality will be identical.

However, the iPad needs to use the ui container ViewController to display 6 UIViewControllers at once.

Obviously this is impossible on the iPhone so I’m resorting to a UIPageViewController on IPhone.

My question is this: given that the UIViewControllers for the 6 “screens’ are identical, is there a way to do this with adaptive layout and storyboards, or do I need to have two storyboards and duplicate all the UIViewController code for iPad and iPhone?

@adamrush Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hello annemarie1185,

Sorry for the delay in responding :]

In complex situations like this, I would probably do most of this in the Storyboard and then in code swap out the UIPageViewController dependant on the size class. You could still re-use ViewControllers for both iPad & iPhone but in code swap the Paging vs. Container.

I hope this helps,
Adam

Great tutorial. I’m on Xcode 11.1 on Mojave. I tried to control-drag from the image view to the controller’s view (I did this in the document outline) and the context popup doesn’t have and Equal Heights option. I ended up dragging to Safe Area and was able to edit the constraint manually. Is this an Xcode 11 change or was I not dragging correctly?