IOS 8 vs iOS 7 Autorotation

Here is a simple one-view application:

- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. self.view.backgroundColor = [UIColor greenColor]; } - (BOOL)shouldAutorotate { return YES; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight; } 

The outputs in iOS 8 are different from each other.

iOS 8 output

iOS 7 output

This is due to the difference in the boundaries of UIWindow on iOS 8 and iOS 7. How do I get the behavior of iOS 7 like?

+6
source share
2 answers

This seems like an error in Xcode 6 or iOS 8. After switching to the storyboard from xib, the problem disappeared.

0
source

In IOS8, the list of possible orientations should be in the Info.plist file, the shouldAutorotate method returns YES by default.

Take a look at the discussion and documentation below:

fooobar.com/questions/226383 / ...

UIKit Link: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/index.html#//apple_ref/occ/instm/UIViewController/supportedInterfaceOrientations

When the user changes the orientation of the device, the system calls this method on the root view controller or the top view that fills the window. If the view controller supports the new orientation, the window and the view controller are rotated to the new orientation. This method is only called if the toAutorotate controller returns YES.

Cancel this method to report all orientations that the view controller supports. The default values ​​for the view controller supported interface orientation are set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom.

The system crosses views supported by the view mode with the orientations supported by the application (as defined by the Info.plist file or application delegate application: supportedInterfaceOrientationsForWindow: method) to determine whether to rotate.

-1
source

Source: https://habr.com/ru/post/973548/


All Articles