I have a UIViewController
with the following code:
- (BOOL) shouldAutorotate {
return NO;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationPortrait;
}
I am not using a UINavigationController
. When this UIViewController
is being displayed, the device will still rotate to landscape. I am targeting iOS 9, what's the issue here?
So the issue was that I had defined the allowed orientations in info.plist
which apparently overrides anything you do anywhere else throughout the project.
To correct the issue I removed the entries from info.plist
and defined them in the project settings. Now everything works as expected.
I don't think Bryan's answer works,for changing the orientations in project settings also changes the info.plist
as @mrhangz commented.
If the issue is iOS9 only,it is probably due to the new feature of iOS9 in iPad called Split view
.The iOS9 enable Split view
by default in particular iPad device,see Apple documents here.
The split view
forced your app to support all orientations in all view once adoptted.So if you set all orientations support in either info.plist
or target general setting,and then split view
is supported by default,which will ignore the orientation setting though supportedInterfaceOrientations
in your viewController and support all orientations.
As the document written,if you checked Requires full screen
in your target settings,then your app will not support split view
.Now you can control orientations in code again.
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