PhoneGap: Device orientation under iOS

女生的网名这么多〃 提交于 2019-12-09 19:10:28

问题


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?


回答1:


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

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!




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/29549782/phonegap-device-orientation-under-ios

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