I found a small behavior change between 7.1 and 8 on the UIViewController shouldAutorotate
method.
The Apple View Controller Programming Guide states that This method is called before performing any autorotation.
However I noticed that when I simply disable shouldAutorotate (return NO), the method is called on Portrait -> Landscape rotation, but not on the following Landscape -> Portrait rotation. Again the method should always be called as I understand it. This occurs when running on iOS 8, but not on iOS 7.1.
This seems related to a new method in the call stack in iOS8 :
[UIWindow shouldAutorotateToInterfaceOrientation:checkForDismissal:isRotationDisabled]
I could not find Is there any description of this method and its behavior, any idea where I could find more information about this internal method ?
Simple steps to reproduce this:
- Create a new Single View Application project in Xcode
Update your
ViewController.m
to implement shouldAutorotate- (BOOL)shouldAutorotate { UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; NSLog(@"%s orientation is %@", __PRETTY_FUNCTION__, [self stringFromDeviceOrientation:orientation]); // Disable autorotation of the interface. return NO; } - (NSString *) stringFromDeviceOrientation:(UIDeviceOrientation)uido { NSString *orientation = @"UIDeviceOrientationUnknown"; switch (uido) { case UIDeviceOrientationPortrait: orientation = @"Portrait"; break; case UIDeviceOrientationPortraitUpsideDown: orientation = @"PortraitUpsideDown"; break; case UIDeviceOrientationLandscapeRight: orientation = @"LandscapeRight"; break; case UIDeviceOrientationLandscapeLeft: orientation = @"LandscapeLeft"; break; case UIDeviceOrientationFaceDown: orientation = @"FaceDown"; break; case UIDeviceOrientationFaceUp: orientation = @"FaceUp"; break; default: break; } return orientation; }
Run on simulator iPhone 5s (7.1) :
shouldAutorotate
is called when switching to Landscape and back to Portrait- Run on simulator iPhone 5s (8.0) or iPhone 6 :
shouldAutorotate
is called when switching to Landscape but it is not called when switching back to Portrait.