iOS8 how to understand interface orientation from UIViewControllerTransitionCoordinator?

2.1k views Asked by At

I'm debugging a project that was working fine in iOS7.1, but does not lay out it's content properly in iOS 8.0. I've narrowed the issue down to this method:

 [self orientRootViewControllerForOrientation:rootViewController.interfaceOrientation];

iOS8 no longer returns correct UIInterfaceOrientation from rootViewController.interfaceOrientation, instead it returns "upside down".

Reading the documentation, I'm confronted with a cryptic message:

Use viewWillTransitionToSize:withTransitionCoordinator: to make interface-based adjustments.

Reading documentation on UIViewControllerTransitionCoordinator, I don't see it having any properties. How can I modify my method that expects an interface orientation to get it's orientation from UIViewControllerTransitionCoordinator?

1

There are 1 answers

0
lazi74 On

Basically you are supposed now to layout your content based on the available size, no more on the rotation. Which results in big pains to support older rotation-based code.

The view controller transition coordinator provides a UIViewControllerTransitionCoordinatorContext that has a rotation factor. This could give you the hint you need ? This blog post mentions this too.

You also have the usual device ([UIDevice currentDevice].orientation) or status bar orientation. In case you are working on iOS 6 rotation methods, this post has relevant informations too.