I have an app made up of a lot of view controllers... in the project summary I've set Portrait orientation as the only supported device orientation.
However, the app still gets messed up when turned sideways.
My question is, is there a way to globally disable autorotation through app delegate or something?
Or do I have to go into all of my view controllers and add the "shouldAutorotateToInterfaceOrientation" method?
Just don't want to miss adding it to one or something...
Thanks!
There are three kinds of Device orientation keys there in the
info.plist
now.Third one is I think for non-universal apps and rest two above are for iPad and iPhone.
You should give them a try.
in root view controller's method:
set 'return NO';
this should do for all the Views.
Haris Hussain's answer appears to be deprecated now, as of IOS 6, but there are new methods available for limiting/enabling rotation.
Here are the methods listed in the UIViewController header:
Note that shouldAutoRotate doesn't seem to work if you start the app in an already rotated state!
In Info.plist expand "Supported interface orientations" and remove Landscape items to make your application only run in portrait mode.
If you're supporting iPad, then you SHOULD NOT uncheck the landscape orientations, as it will prevent your app from being accepted by Apple on App Store.
To prevent rotating before the app shows your first screen, put this inside your AppDelegate.m
This method works and tested in iOS 7.1 above.
After struggling to set in UIViewController's
shouldAutorotate
andsupportedInterfaceOrientation
methods, with no success in iOS6, I found the most effective is to set it in app delegate.However returning
UIInterfaceOrientationMaskPortraitUpsideDown
was crashing my app. I dont know whats wrong I was doing!