2

I make a simple application to iPhone with the phonegap library (Phonegap 0.9.6). I like to use the orientation function, but if I rotate the device, the screen don't change. I tried a few things, but none worked. I added these lines to _Info.plist:

   <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
   </array>

Next try to add these same lines to the PhoneGap.plist. I try to use javascript, but don't work. Anybody know thw solution?

BaluEdo
  • 119
  • 2
  • 11
  • 1
    From what I can tell from the PhoneGap docs, orientationChanged isn't supported. I've seen mention of it before but may have been dropped in 1.0 – JLeonard Aug 20 '11 at 00:27

3 Answers3

2

You need to add these to YOUR_APP_NAME-Info.plist :

For iPad :

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

For iPhone :

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>
Titouan de Bailleul
  • 12,920
  • 11
  • 66
  • 121
1

I had the same problem, the only thing that worked for me was to add this code to my js (outside of deviceready):

window.shouldRotateToOrientation = function(degrees) {
                return true;
            }

Then add to the xml:

<preference name="Orientation" value="default" />
MrCujo
  • 1,218
  • 3
  • 31
  • 56
  • Still required as of Cordova 5.1.1, iOS 8 ... works on iPhone 6 and in simulator. (The plist solution from Ben Taliadoros also works, but this JavaScript is simpler.) BTW, similar Q/A here: http://stackoverflow.com/questions/10999435/why-doesnt-my-cordova-phonegap-ios-app-rotate-when-the-device-rotates/ – Scott Lawton Jul 14 '15 at 03:19
0

I had the same issue, you need to manually add to the plist file, as far as i can tell it's not copying from the config.xml due to a cordova issue.

So to get full orientation support on all your apple devices make sure the .plist file matches the below:

 <key>UISupportedInterfaceOrientations</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
    <key>UISupportedInterfaceOrientations~ipad</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
      <string>UIInterfaceOrientationLandscapeLeft</string>
      <string>UIInterfaceOrientationPortraitUpsideDown</string>
      <string>UIInterfaceOrientationLandscapeRight</string>
    </array>
Ben Taliadoros
  • 7,003
  • 15
  • 60
  • 97