iOS 8 Rotation Methods Deprecation - Backwards Compatibility iOS 8 Rotation Methods Deprecation - Backwards Compatibility ios ios

iOS 8 Rotation Methods Deprecation - Backwards Compatibility


I just had this issue and I wanted to use the same methods that I was using before (at least for now), so this is what I did.

- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator{    [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];    //The device has already rotated, that's why this method is being called.    UIInterfaceOrientation toOrientation   = [[UIDevice currentDevice] orientation];    //fixes orientation mismatch (between UIDeviceOrientation and UIInterfaceOrientation)    if (toOrientation == UIInterfaceOrientationLandscapeRight) toOrientation = UIInterfaceOrientationLandscapeLeft;    else if (toOrientation == UIInterfaceOrientationLandscapeLeft) toOrientation = UIInterfaceOrientationLandscapeRight;    UIInterfaceOrientation fromOrientation = [[UIApplication sharedApplication] statusBarOrientation];    [self willRotateToInterfaceOrientation:toOrientation duration:0.0];    [coordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> context) {        [self willAnimateRotationToInterfaceOrientation:toOrientation duration:[context transitionDuration]];    } completion:^(id<UIViewControllerTransitionCoordinatorContext> context) {        [self didRotateFromInterfaceOrientation:fromOrientation];    }];}

I'm still not sure if I should use this outside of the animation block since I don't have the duration.

    [self willRotateToInterfaceOrientation:toOrientation duration:0.0];


The rotation methods are deprecated in the iOS 8 SDK. This will have no effect at all on apps built with the iOS 7 SDK, even running in iOS 8 and probably several future versions of iOS.

As an example, the font property of UIButton has been deprecated since iOS 3.0 and is still available in iOS 7.0.


The deprecated rotation methods you've listed are still called when the app is run on iOS 8+ devices. If you are supporting iOS 7, you may continue to use them without issue. If you are only supporting iOS 8+, it would be wise to use the non-deprecated methods instead.

However, do note that if you implement the new rotation methods and the deprecated ones in the same view controller, when run on iOS 7 the deprecated methods will be called, and on iOS 8+ it will only call the new methods that have replaced those that are deprecated.

For example, if you only implement willRotateToInterfaceOrientation, this method will be called when run on iOS 7 and 8. If you then add viewWillTransitionToSize, iOS 7 will still call willRotateToInterfaceOrientation but iOS 8 will not, instead it will only call viewWillTransitionToSize.