BaluEdo
BaluEdo

Reputation: 119

iPhone Phonegap Orientation problem

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?

Upvotes: 2

Views: 931

Answers (3)

MrCujo
MrCujo

Reputation: 1323

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" />

Upvotes: 1

Ben Taliadoros
Ben Taliadoros

Reputation: 9371

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>

Upvotes: 0

Titouan de Bailleul
Titouan de Bailleul

Reputation: 12949

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>

Upvotes: 2

Related Questions