问题
I have a PhoneGap 3.1 application that I build remotely on PhoneGap Build.
In my app there is a single config.xml
file at the root of the project. This file contains:
<preference name="orientation" value="default" />
However I would like to restrict the orientation to portrait mode in iOS. I've randomly tried :
<preference gap:platform="ios" name="orientation" value="portrait" />
and
<gap:platform name="ios">
<preference name="orientation" value="portrait" />
</gap:platform>
but none of these seem to work.
How can I set preferences for specific platforms?
回答1:
With PGB we now have the ability to add to the info.plist file. So in your config.xml put this:
<gap:config-file platform="ios" parent="UISupportedInterfaceOrientations" overwrite="true">
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</gap:config-file>
Read more and see this exact example here: http://phonegap.com/blog/2014/01/30/customizing-your-android-manifest-and-ios-property-list-on-phonegap-build/
来源:https://stackoverflow.com/questions/20998325/per-platform-configuration-config-xml-on-phonegap-build