Per platform configuration (config.xml) on cordova

北慕城南 提交于 2019-12-25 02:29:07

问题


something like-

<gap:config-file platform="ios" parent="UISupportedInterfaceOrientations" overwrite="true">
   <array>
      <string>UIInterfaceOrientationPortrait</string>
   </array>
</gap:config-file>

like the answer from this question regarding Phonegap.

is there an option for it in config.xml on Cordova?


回答1:


For screen orientation, adding <preference name="Orientation" value="portrait" /> will result in the CLI adding the specific tags in the platform specific config files each time you build (androidmanifest.xml for android and sorry I don't know much about IOS...)

If you want to force the orientation for ios but not android, you can try this :

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

For other options, there are tags that are recognised only by some platforms so you add them to config.xml and the cli uses it or not depending on the platform. See here fore android-only options and here for ios-only options.

For things like plugins, you use the cli to customize each platform, but don't touch config.xml.

For other things unfortunatly you may have to manually edit the specific platform config file (ie androidmanifest.xml) once the platform has been added to the project. When you build the project, those options should be kept in the config file.




回答2:


I know this question has long since been answered, but I found this handy documentation page just this afternoon when building my first Cordova based app:

http://docs.phonegap.com/phonegap-build/configuring/preferences/#orientation

Hope this helps anyone else that stumbles upon this page.



来源:https://stackoverflow.com/questions/24825634/per-platform-configuration-config-xml-on-cordova

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