Days of working on a rotatable iOS app and then have to turn off one orientation because of too many problems?

Completely different designs for iPad and iPhone in both portrait and landscape mode?

All of these difficulties have been bloating up the time and cost of developing iOS native apps, and now with new iPhones 6 coming out, the different screen-sizes call out for better utility and space optimisation – iOS 8 has provided developers with a great tool Adaptive User Interface.

In iOS 8, there is no need to handle rotation, the old way of handling rotations is now deprecated in iOS 8. This is the support for different screen orientation (link)

the action bar has a completely different layout in landscape mode (toolbar pinned to the right).

The UISplitViewController now can be used on iPhone.

Size Classes

The Horizontal size class has Regular/Compact, combined with Vertical size class Regular/Compact we have 4 modes.

UITraitCollection

The horizontal and vertical size classes are called traits.

These size classes, plus current interface idiom and the display scale is what called a trait collection. All the information of size classes are kept in UITraitCollection object: (self.traitCollection)

<UITraitCollection: 0x7f833b623e80; _UITraitNameUserInterfaceIdiom = Phone, _UITraitNameDisplayScale = 2.000000, // RETINA _UITraitNameHorizontalSizeClass = Compact, _UITraitNameVerticalSizeClass = Regular, _UITraitNameTouchLevel = 0, _UITraitNameInteractionModel = 1>

Horizontal=Compact & Vertical=Regular => phone is in portrait mode.

When the phone change orientation: the function below is called automatically:

– (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection

the previous trailCollection is kept as parameter, when the current trailCollection has the new updated values.

 

Advertisements