Cordova:如何在启动时将应用程序方向锁定为横向而不是横向反转?

问题描述 投票:0回答:2

我正在构建一个基于倾斜的游戏,并希望将方向锁定到1个特定的横向方向(iOS上的UIInterfaceOrientationLandscapeRight)。但是,如果您将cordova Orientation首选项设置为landscape,它仍然可以旋转180度到横向模式,这对我来说是不可接受的。这是科尔多瓦的缺点吗?我需要这个,而且本地做的很简单,所以似乎应该有一个简单的方法来做到这一点。

我知道cordova-plugin-screen-orientation,但它只会在你的javascript开始运行后才会发生,这对你的启动画面来说已经太晚了。

cordova orientation screen-orientation
2个回答
0
投票

找到了解决方案:cordova允许您通过config.xml文件编辑本机属性。我觉得这应该由cordova本身支持,但这将有效:

<platform name="android">
    <edit-config file="AndroidManifest.xml"
                 target="/manifest/application/activity[@android:name='MainActivity']"
                 mode="merge">
        <activity android:screenOrientation="landscape"></activity>
    </edit-config>
</platform>

-1
投票

请选择landscape,然后创建构建

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.