Panda Pajama
Panda Pajama

Reputation: 1441

iOS application won't rotate on iPhone but will rotate on iPad

I made my gles app, and tested it on my iPad. It is supposed to work only on landscape mode, so I have my Info.plist like this

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

I set landscape-right only for iPhone so the splash screen shows correctly (it seems you can't set separate splash screens for landscape-right and landscape-left on the iPhone)

The application runs fine, but on a friend's iPhone, the app runs on portrait mode, and won't rotate to either landscape. The rotation lock is off.

I am not doing anything in particular from my code to support rotations, as just setting my Info.plist worked perfectly on my iPad.

The iPhone simulator automatically turns to landscape, and retains the landscape rendering even if I rotate it.

What could be causing this? I also tried allowing both landscape rotations, but no dice.

Upvotes: 1

Views: 1281

Answers (1)

escrafford
escrafford

Reputation: 2403

ios6 introduced new ways to deal with orientation changes - I'd guess your friend's iphone is running ios5. See the UIViewController docs to see how to deal with both versions:

Handling View Rotations

In iOS 6, your app supports the interface orientations defined in your app’s Info.plist file. A view controller can override the supportedInterfaceOrientations method to limit the list of supported orientations. Generally, the system calls this method only on the root view controller of the window or a view controller presented to fill the entire screen; child view controllers use the portion of the window provided for them by their parent view controller and no longer participate in directly in decisions about what rotations are supported. The intersection of the app’s orientation mask and the view controller’s orientation mask is used to determine which orientations a view controller can be rotated into.

You can override the preferredInterfaceOrientationForPresentation for a view controller that is intended to be presented full screen in a specific orientation.

In iOS 5 and earlier, the UIViewController class displays views in portrait mode only. To support additional orientations, you must override the shouldAutorotateToInterfaceOrientation: method and return YES for any orientations your subclass supports. If the autoresizing properties of your views are configured correctly, that may be all you have to do. However, the UIViewController class provides additional hooks for you to implement additional behaviors as needed. Generally, if your view controller is intended to be used as a child view controller, it should support all interface orientations.

When a rotation occurs for a visible view controller, the willRotateToInterfaceOrientation:duration:, willAnimateRotationToInterfaceOrientation:duration:, and didRotateFromInterfaceOrientation: methods are called during the rotation. The viewWillLayoutSubviews method is also called after the view is resized and positioned by its parent. If a view controller is not visible when an orientation change occurs, then the rotation methods are never called. However, the viewWillLayoutSubviews method is called when the view becomes visible. Your implementation of this method can call the statusBarOrientation method to determine the device orientation.

Upvotes: 3

Related Questions