【发布时间】:2018-11-06 23:04:58
【问题描述】:
我的 Cordova 应用在 iPhone 上运行时从不旋转到横向模式。
我尝试了许多解决方案,将这些行放在 config.xml 文件中:
<preference name="ios-orientation-iphone" value="portrait and landscape" />
<preference name="ios-orientation-ipad" value="portrait and landscape" />
<preference name="Orientation" value="default" />
我还在<platform name="ios"> 块内添加了以下行:
<preference name="Orientation" value="all" />
然后我在 index.js 文件中做了以下操作:
window.shouldRotateToOrientation = function (degrees) {
return true;
};
最后,我尝试在 res/native/ios 文件夹中创建一个自定义 plist 文件,因为我注意到生成的 plist 文件不包含这些行:
<key>UISupportedInterfaceOrientations</key>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
我不知道下一步该做什么。谢谢
【问题讨论】:
-
如果删除所有这些会发生什么?默认情况下,Cordova 应该允许横向和纵向。仅添加:
<preference name="Orientation" value="default" />到您的 config.xml,如果您想明确说明 -
只需在 Xcode 中进行设置即可。