Portrait and landscape in iPad are both regular size classes !?!

I'm beginning to use all autolayout and size classes in my app. As advised, I'm looking for compact and regular size classes to handle different layout for different orientation for both iPhone and iPad. However, for iPad, the size classes are always regular, no matter if it's landscape or portrait. Apple advised us to not depend on orientation for laying out views but that's the only way to detect different orientations in iPad, size classes is not enough. I have a view that will display 2 rectangle side by side in landscape, but one below another in portrait.


Can someone tell me what is the best practices for this scenario?


Thanks

Which versions iOS are you supporting?

I believe the only way is to use viewWillTransitionToSize and programmatically compare height vs. width to decide which layout to use. You then have to install / remove (or activate / deactivate) sets of constraints. With split screen multitasking, now there is a whole continuum of sizes from the current iPad landscape, through square, all the way to very skinny vertical. Initially I was quite disappointed they didn't allow you to distinguish without code but now it starts to make a bit more sense.

I'm supporting iOS 8 and forward.

As I understand it, the new API is meant to make it easy for (and encourage) developers to use a consistent layout, regardless of device orientation or other factors. Size classes provide an abstraction for determining layout without having to consider the window's bounds or other state information to figure out why its bounds have a particular size.


Still, for some apps there may be special cases where device orientation matters. If your app falls into this case, your view controller can override

viewWillTransition(to:with:)
and call the
animate(alongsideTransition:completion:)
method of the passed-in coordinator. Use the
targetTransform
property of the
UIViewControllerTransitionCoordinatorContext
instance passed as the animation's parameter to update the transform of each "orientation-aware" view or its content.


override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)

    let animation: (UIViewControllerTransitionCoordinatorContext) -> Void = { context in
        // use context.targetTransform to update your views, usually by applying a counter-rotation
    }

    coordinator.animate(alongsideTransition: animation)
}

But not for Lauchscreen T___T Apple is sooo Apple ))))))

Portrait and landscape in iPad are both regular size classes !?!
 
 
Q