How to support only portrait mode in the iPhone app
I have a weird problem with an iPhone app I am developing. I want my app to support portrait mode ONLY , but for some reason I can't do it (device and simulator).
To only support portrait mode, I did the following:
- In the TARGET summary section in Xcode, I only selected the portrait.
- All my ViewControllers are implementing
shouldAutorotateToInterfaceOrientation
But as I said it won't work and the weird result is that the app supports ALL orientation (portrait, upside-down, left, right-right).
Any ideas?
this is how i implement shouldAutorotateToInterfaceOrientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
NSLog(@"Checking orientation %d", interfaceOrientation);
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Now I notice that when I rotate my phone, I get the following message:
"Two-stage rotation animation is deprecated. This application should use smoother one-stage animation."
What does it mean?
source to share
Several ViewControllers are possible on the screen. UITabBarController
itself is UIViewController
, and it only lets through requests shouldAutorotateToInterfaceOrientation:
to viewControllers inside if it chooses. The default implementation does this, but if you subclass it, the Xcode generates (just like iOS 5.1).
source to share
Go to info.plist file. Right click to open it as source. And look for this line. For me on iPad, it goes something like this:
<key>UISupportedInterfaceOrientations~ipad</key>
Remove all other orientation and keep the only one you need. Like this:
<array>
<string> UIInterfaceOrientationPortrait </string>
</array>
source to share