Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Size Classes / Trait Collection in iOS be used programmatically when not using Autolayout

I am not using Auto Layout however I wish to be able to make my (very complex) app adapt to Split View multi-tasking on the iPad. For this, ideally to do it right, I want to support size classes without going down the Auto Layout route. Watching the WWDC 406 session it seems that one can programmatically do this, but I am not sure since they've used Autolayout in every example and even Interface builder does not support it otherwise.

Will I run into any issues if I was to listen to notifications regarding trait changes and do everything programmatically or using pins and struts? I have everything defined in Storyboards but I'd like to be able to support differently sized view controllers when the iPad is showing two apps side by side in iOS 9. Please advise.

like image 647
strangetimes Avatar asked Jul 07 '15 01:07

strangetimes


People also ask

What is Autolayout What is size classes and how can we use it?

In easy way we can say Autolayout is used for displaying same layout comatible on different different iPhone/iPad screen sizes (ex. Keep button in center for all screen sizes) while through Autoresizing classes we can set a different layout for a particular screen size.

What is trait collection iOS?

The Trait Collection Here is the definition of trait collection from the Apple developer document: The iOS interface environment for your app, defined by traits such as horizontal and vertical size class, display scale, and user interface idiom. There is one protocol in the UIKit called UITraitEnvironment.

What is iOS Autolayout?

Auto Layout is a constraint-based layout system. It allows developers to create an adaptive interface that responds appropriately to changes in screen size and device orientation.


1 Answers

From Apple Documentation:

Enabling Size Classes in Interface Builder

Size classes require Auto Layout. If the checkbox Use Auto Layout isn’t selected when you select Use Size Classes, Xcode prompts you to enable Auto Layout.

like image 116
SwiftArchitect Avatar answered Nov 15 '22 05:11

SwiftArchitect