11

Although cross platform development for mobile devices is so good. There isn't a simple option to disable auto-rotate or lock into one orientation i.e. portrait or landscape.

Is there anyway either in Jquery Mobile, PhoneGap, XUI anywhere ?

If yes then please help. Its driving me nuts.

Mustafa Hanif
  • 140
  • 1
  • 3
  • 8

4 Answers4

15

To complete the answer above.

On iPhone add this to -info.plist:

<dict>
`.....
    <array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
    </array>
..........
</dict>

on Android to AndroidManifest.xml

<activity   ........      android:screenOrientation="portrait">
David Dehghan
  • 22,159
  • 10
  • 107
  • 95
  • 2
    is there a way to do this on the fly? For example I have 2 pages which do not need to support orientation changes, but one that does. Any jquery mobile to support this? – Mike Aug 11 '12 at 15:15
5

For iOS, edit the PhoneGap.plist file (e.g. in Xcode). Make sure only portrait is set and uncheck autorotate.

On Android, you need to edit AndroidManifest.xml. Add android:screenOrientation="portrait" in the activity.

dave1010
  • 15,135
  • 7
  • 67
  • 64
1

Cordova allows you to set this in config.xml

Just add this line within the <widget></widget> tags:

<preference name="Orientation" value="portrait" />

You can also use landscape above for the opposite effect.

Source: Apache Cordova DOcumentation - The config.xml File

ak5
  • 149
  • 1
  • 2
0

On PhoneGap you can now specify the application wide orientation in the config.xml file (note that you then won't receive any orientationchange event anymore, so this isn't the right solution if you just want to enable/disable the auto rotation on some pages only)

<preference name="orientation" value="portait" />
user276648
  • 6,018
  • 6
  • 60
  • 86