ios – 如何在我的Cordova / Phonegap应用程序中仅允许这些方向?

前端之家收集整理的这篇文章主要介绍了ios – 如何在我的Cordova / Phonegap应用程序中仅允许这些方向?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我使用Cordova创建了一个iOS(iPhone)应用程序,并且只想允许以下方向:

>肖像
>左侧风景
>风景正确

这也意味着不应该允许“倒置”:

XCode screenshot device orientation

我知道我可以在Xcode中设置它,但是当我开始新的Cordova构建时,此设置会被覆盖.

所以我检查了Cordova文档并发现了这个:http://cordova.apache.org/docs/en/5.1.1/config_ref_index.md.html#The%20config.xml%20File

它说我可以在config.xml中设置方向如下:

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

但我没有看到如何设置更精细的粒度设置,如上所述.如何才能做到这一点?

注意:我在Cordova 5.1.1上

解决方法

你可以使用config.xml’

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

以及docs中所述的shouldRotateToOrientation(度)回调,如下所示:

onDeviceReady: function() {
    app.receivedEvent('deviceready');
    window.shouldRotateToOrientation = function(degrees) {
        return degrees !== 180;
    };
},

猜你在找的Xcode相关文章