强制在Phonegap/Cordova iOS应用中启用正确的横屏模式。

4

如何强制 Phonegap 应用仅使用正确的横屏方向?

我知道对于原生 iOS 应用程序这是可能的(请参见 Xcode 中设置的截图)enter image description here

对于 Phonegap,我能找到的唯一选项是在 config.xml 中指定方向偏好:

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

这个设置会强制应用在横屏模式下显示,但允许你将屏幕旋转180度。这并不是期望的结果。

2个回答

2

对于 IOS

在 config.xml 中设置:

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

或者

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

在资源文件夹中的ios文件夹下的"ProjectName"-info.plist文件中,对于"UISupportedInterfaceOrientations"设置为:
UIInterfaceOrientationLandscapeLeft

或者

UIInterfaceOrientationLandscapeRight

或者

对于竖屏方向:

UIInterfaceOrientationPortrait

或者

UIInterfaceOrientationPortraitUpsideDown

根据您的需求选择适用的Include。


0

解决方案已找到:

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


你把它加在哪里了? - socca1157
在您的config.xml文件中。请注意:此解决方案仅适用于使用build.phonegap.com构建您的应用程序。如果使用Cordova(本地)构建,则可以在info.plist文件中设置屏幕方向设置。您可以在此处找到有关此设置的更多信息:http://docs.build.phonegap.com/en_US/configuring_config_file_element.md.html - StackFlower
还需要一个 </gap:config-file>,但无法解决我的问题,即在iPad上启动应用程序时旋转方向错误。 - svante

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接