Paul Andrew Herbert
Paul Andrew Herbert

Reputation: 367

How do I opt into Xcode's Compatibility mode re automatic layout across different devices?

Good afternoon,

With regards to Apples recent Email stating the following:

Apps for iPhone or iPad must be built with the iOS 13 SDK or later and use an Xcode storyboard to provide the app’s launch screen.

My apps on the app store targeted iOS9 and I have not really done anything with them for a good four or so years now. They have just been ticking over nicely. In trying to update my apps to fall inline with Apple's request I am having some layout issues.

The apps were written for iPad 768 x 1024 points and iPhone 320 x 568 points. Since I wrote the apps Apple have introduced devices with larger screens etc. such as the iPad 12.9 Pro with 1024 x 1366 points or the iPhone 11 Pro Max with 414 x 896 points.

If I run my apps without changing any code using the latest Xcode and target iOS 12.1 and above the apps work just fine. That is, they auto resize from 768 x 1024 or 320 x 568 to the newer devices larger point count. It's kinda magic to be honest and it just works with no additional code needed, constraints, size classes, auto layouts etc. required. Xcode is obviously performing some kind of magical resize on the View without my intervention. Is this 'Compatibility mode'?. In addition the resize also respects the safe areas of these new devices as shown below:

Using Launch images and Asset.xcassets

Now, when i remove the 'Launchimage' containing my launch screens from the 'Asset.xcassets' and add a 'Launchscreen.Storyboard', as requested by Apple, I appear to lose the resizing magic as stated above. Instead my app appears on the new larger point devices but at the original points of 768 x 1024 or 320, 568. Example below:

Using Storyboard Launchscreen

My app rotates and I handle the rotation in code based on the original points 768 x 1024 and 320 x 768. However, even using these points, Xcode or on running the app it just new to auto resize these points to the larger point system of the new bigger devices.

My question is now I have switched from Launch Images to a Launchscreen.Storyboard, how can I switch on the auto resizing that the old Launch Images way of doing things gave me? Or, is my free launch over?

I know that we live in a world of auto layouts, constraints and class sizes but it seems a bit of a backward step that I did not have to do anything with my code for use with larger point devices, when using Launch images, but on switching to a Launchscreen.storyboard, maybe I do?

I am not trying to be lazy here and will do what I need to do. I am just trying to understand the mechanism that was in place with Launch images that auto resized my apps automatically and if it's available now I have switched to a Launchscreen.storyboard.

After weeks of hard googling, playing with every Interface Builder option and failing to find a solution, if anyone can enlighten me, it would be most appreciated.

Kind regards

funkychimp

Upvotes: 0

Views: 204

Answers (1)

Gereon
Gereon

Reputation: 17874

Launch Images were basically telling the OS which resolutions you were supporting. On larger displays, your views would be automatically scaled.

Now that launch images are gone, there is no more indication to the OS which resultion(s) the app is supporting, so everything needs to by dynamic. In your words, your free launch is over, indeed.

What you need to do is give your views the auto-layout treatment, so that they can auto-adapt to whatever screen size. Looking at your poker timer app example, that should not be too hard to implement. You might want to learn about UIStackView, this is a pretty useful tool for building layout like yours.

Upvotes: 3

Related Questions