0

I have read blogs about Adaptive Layout and I have done some tutorials to see it in practice. I now want to try to migrate an existing iOS app to support Adaptive Layout / Size Classes. On the internet there is a lot to read about Adaptive Layout on it now, blogs, tutorials etc. But they are all based on setting up a new project. I can not seem to find some sort of step by step guide on how to migrate an existing app. Which step to take first, where to look for second, which pieces of code to replace (f.e. initWithFrame). Does somebody know some sort of guide to follow when migrating an existing app? Thanks in advance.

jww
  • 97,681
  • 90
  • 411
  • 885
Brabbeldas
  • 1,939
  • 4
  • 20
  • 32

2 Answers2

0

The following steps should be taken:

First, to adopt Adaptive Layout and Universal Storyboard in an existing app, you need to turn your existing storyboard into an universal storyboard — a storyboard that can handle your interface for any screen size. Open up your storyboard and go to the info panel and check both the box for Use Auto Layout and Use Size Classes.

Second, you need to enable Fulscreen Mode.

According to Apple: At runtime, the system looks for a storyboard launch screen file, so as to let the system know your app supports iPhone 6 screen sizes, including a storyboard launch screen file in your app’s bundle If such a file is present, the system assumes your app explicitly supports the iPhone 6 and 6 Plus and runs it in fullscreen mode.

Add a new file to your app by going to New File…. In iOS > User Interface, there is a new file type called Launch Screen that adds a new launch screen to your app. Finally, go to your project’s general settings and choose your new xib file for the field Launch Screen File.

EDIT:

You also can migrate your App Icons and Launch Images to an Asset Catalog. Go to your project’s general settings and click Use Asset Catalog for App Icons Source. Xcode will ask you to migrate app icons to an asset catalog and to also migrate existing launch images.

Note: If you still support iOS 7 and/or earlier, you still need to supply 4-inch launch images. If you don’t, your app will display in 3.5″ mode.

Brabbeldas
  • 1,939
  • 4
  • 20
  • 32
0

As far as I know, migrating your app to support Adaptive layouts/Size Classes is most likely starting a new project.

Follow the steps for migrating your app.

  1. Open your project in the latest Xcode.
  2. Select the view controller in the storyboard.
  3. In the Attributes inspector select the "Size" to Inferred. Your view controller will be displayed in square dimensions.
  4. Now based on the size classes you need to set up your constraints.

And coming to the code you need to override the method

- (void)updateConstraintsForTraitCollection:(UITraitCollection *)collection

Depending on the size class you need to set up your constraints programatically.

Here goes the sample code.

- (void)updateConstraintsForTraitCollection:(UITraitCollection *)collection
{
    if (collection.verticalSizeClass == UIUserInterfaceSizeClassCompact) {
        //constraints for this specific class will go here
    } else {
        //default constraints
    }

}

The only thing you will overcome in this process is setting up the UI. Other than that everything is like starting up a new project.

Hope this helps you. :)

i 4322946
  • 173
  • 2
  • 9