The iOS application I am working on has a view that needs to be locked in landscape orientation. Up to this point, that was accomplished by using the shouldAutorotate
and supportedInterfaceOrientations
methods, but on an iPad Air 2
running iOS9 beta5
, these methods never fire and the orientation is not locked.
I have tried on the following devices, methods fired on all except the Air2 (running debug with Xcode beta6): iPhone 6+, iPad Mini, iPad Air 2, iPad 2, iPad 3
The methods not firing are as follows:
- (BOOL)shouldAutorotate {
return YES;
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationMaskLandscapeRight;
}
View controller is displayed via presentViewController
Make sure Rotation Lock is turned off: swipe down from the top right-hand corner of your screen to open Control Centre. Then tap the Rotation Lock button to make sure it's turned off.
If you have an iPhone or iPad with Face ID, swipe down from the top-left corner of the screen. If your iPhone or iPad has a Home button, swipe up from the bottom of the screen. Tap the Rotation Lock button to activate the lock. When active, the Screen Rotation lock icon will be red on a white background.
Multitasking can be turned off by adding the UIRequiresFullScreen
field to the application's info.plist with the boolean value YES
, and this will allow the orientation delegate methods shouldAutorotate
, preferredInterfaceOrientation
, and supportedInterfaceOrientations
to fire.
As far as locking orientation AND supporting multitasking, I have not found a way to do this.
The 'Requires full screen' setting can be enabled from 'General' of the target settings.
With this enabled, the orientation code will now run. As mentioned by ackerman91, you can also set UIRequiresFullScreen
boolean to YES in the application info.plist or in the target 'Info' tab.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With