Question

My app is fixed to landscape mode, yet during viewDidLoad() and even viewWillAppear(), the following portrait dimensions still return:

self.view.bounds.size.width = 320.00
self.view.bounds.size.height = 480.00

It's not until viewDidAppear() that the actual landscape dimensions result.

self.view.bounds.size.width = 480.00
self.view.bounds.size.height = 320.00

I find this weird. Why does this happen!? and how can I fix this?

Was it helpful?

Solution

In your app's info.plist file, specify the key:

 UISupportedInterfaceOrientations

with values for landscape left and right:

enter image description here

EDIT:

The raw plist code should look like this:

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

Edit 2

You also need this key which determines the initial orientation of the status bar:

 <key>UIInterfaceOrientation</key>
 <string>UIInterfaceOrientationLandscapeRight</string>

Further, you need to make sure that ALL of your view controllers (tabbar, navbar, regular view-controllers) implement

 shouldAutorotateToInterfaceOrientation

and return a Landscape (left or right) value.

Here is an Apple docs article on the subject:

Technical Note TN2244

And finally, here are some other SO posts on this topic: post 1 and post 2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top