PhoneGap 3.0.0 Locking orientation [duplicate]

℡╲_俬逩灬. 提交于 2020-01-31 19:35:25

问题


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.


回答1:


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

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

<activity android:name=".SomeActivity"
          android:label="@string/app_name"
          android:screenOrientation="landscape">



回答2:


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>


来源:https://stackoverflow.com/questions/18477050/phonegap-3-0-0-locking-orientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!