Autorotation landscape only

Simple task. You want to create a landscape only iOS app that starts with home button right. Sounds easy, doesn’t it? Additionally we’d like that to work on at least iOS 5 and iOS 6.

Let’s have a look how this is done. According to documentation this should be easy. In your projects summary page you configure your app as follows.

Now in your app’s Info.plist you add the line

When you now start up your app then … surprise, surprise your app will start app landscape with the home button on the left.

Thanks to a bit of research I found out that apparently the initial orientation field of the .plist is simply ignored. Instead the first entry of your supported interface orientations is taken as the initial one. Since in your summary page left is first it’ll be chosen as startup orientation.

So what you have to do is open your Info.plist as source code and rearrange the XML entries so they look like this:

<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeRight</string
<string>UIInterfaceOrientationLandscapeLeft</string>
</array>

Now your app will start up correctly. One thing still remains strange though. On iOS 5 your view controller will receive a willRotateToInterfaceOrientation:duration: callback. On iOS 6 it won’t. So be careful if your code relies on autorotation being called initially.

Update: I just noticed that you can drag lines in the plist editor, so you can do that as an alternative to editing the xml file.

Share this: