2

I am working on a game in PhoneGap. My game needs the screen to be "locked" into landscape mode. I need it to be locked so that you can't turn the device into the other landscape mode, rotating the screen (so, no matter which way the device is rotated, the screen will not change orientations. It will stay the same way as it was before). I have tried looking at this question, but it didn't work for me. I need a solution that I can use easily, and preferably with Android and iOS. I am using the tools for PhoneGap, so in the terminal, I run:

phonegap run android

to build and install my app onto my tablet.

Community
  • 1
  • 1
pjrader1
  • 491
  • 7
  • 22

2 Answers2

3

For locking orientation in IOS : just open the project in Xcode and click on project and inside summary you can select the orientations enter image description here

FOr Android add android:screenOrientation="landscape" to each activity eg:

<activity android:name=".SomeActivity"
          android:label="@string/app_name"
          android:screenOrientation="landscape">
Arjun T Raj
  • 3,187
  • 1
  • 21
  • 44
  • In PhoneGap 3.0.0, where are the projects files? I know in previous versions of PhoneGap, you just opened the project in an editor, like XCode, and edit it from there. In PhoneGap 3.0.0, you use command line tools to build and install the app onto devices. – pjrader1 Aug 28 '13 at 22:13
  • projectrootfolder ->platforms->ios/android – Arjun T Raj Aug 29 '13 at 04:27
  • Yep! It sure worked! I also expected "phonegap run android" to rebuild the entire Android project, but it didn't. I suppose if it did, I could work around that with some sh scripts. – pjrader1 Aug 30 '13 at 04:30
  • 3
    Why should it have to be added here? Shouldn't it look at the config.xml in the 'www' folder and generate this from the `` when it builds for that platform? – jshbrntt Jan 02 '14 at 14:45
  • @SyntheCypher PhoneGap only creates the project files when it first generates the project. Afterwords it just updates the files in each project (the ones in your www folder). – pjrader1 Apr 10 '14 at 05:13
1

I had to do the following (cordova 3.3): in *-info.plist - i had:

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

I change it into:

<key>UISupportedInterfaceOrientations</key>
<array/>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>
Elia Weiss
  • 8,324
  • 13
  • 70
  • 110