简体   繁体   中英

PhoneGap: Device orientation under iOS

I created a new PhoneGap app using the following

phonegap create hello-world com.hello.world HelloWorld

With PhoneGap 4.2.0-0.25.0. However, I am not able to change the viewport orientation to landscape on the iPhone or the simulator. I tried the following two methods within my config.xml.

<preference name="orientation" value="default" />

<preference name="orientation" value="landscape" />

I am still not able to use the app in landscape mode. (Of course I disabled any rotation locks on my iPhone.)

Does anybody know how to solve this?

I just tried it and it worked fine. Be sure to set the correct options in XCode like this: XCode肖像更改

Before you do this you build a clear Project like this ->

  1. cordova create OrientationChange com.example.com OrientationChange
  2. cd OrientationChange
  3. cordova platform add ios
  4. cordova plugin add org.apache.cordova.console (you don't need this for the orientation change but it's useful for debugging).
  5. cordova build

Run the Project in XCode (6.3 is the actual version) and give it a try - it should work!

Let me know if you need further help!

As the user above stated, you can simply change it within your Xcode project. However, this seems like a bug that has yet to be fixed with Cordova, since the Orientation setting is supposed to set this per the Cordova documentation.

http://cordova.apache.org/docs/en/4.0.0/config_ref_index.md.html#The%20config.xml%20File

I've run into the problem where a published project had to be rebuilt and I forgot to modify these settings in the Xcode project itself, resulting in the published project not having rotation capabilities. Keep that in mind.

Specific to cordova :

File called appDelegate.m in ios where is orientation is set for complete ios app in code just change that orientation and that will fix the issue, tested on IOS9

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM