ios – iPad上的Cordova锁定方向失败

我正在使用cordova 3.5.0-0.2.6(最后一个稳定版本).
我在锁定iPad设备的方向时遇到问题.
在iPhone上它正常工作,但在iPad上方向没有锁定.

我想锁定整个应用程序,而不仅仅是页面.

这是我当前的config.xml:

<?xml version="1.0" encoding="utf-8"?>
<widget id="com.domain"
        version="version"
        xmlns="http://www.w3.org/ns/widgets">
    <name>xxx</name>

    <description>Lorem ipsum</description>

    <access origin="*"/>

    <author email="x@x" href="https://x.com">x</author>

    <content src="index.html?platform=cordova"/>

    <feature ...></feature>

    <preference name="permissions" value="none"/>
    <preference name="orientation" value="portrait"/>
    <preference name="show-splash-screen-spinner" value="true"/>
    <preference name="auto-hide-splash-screen" value="true"/>
    <preference name="prerendered-icon" value="true"/>
    <preference name="disallowoverscroll" value="true"/>
    <preference name="webviewbounce" value="false"/>

    <preference name="StatusBarOverlaysWebView" value="false"/>
    <preference name="StatusBarBackgroundColor" value="#000000"/>
</widget>

生成的plist文件如下所示:

<key>UISupportedInterfaceOrientations</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations¨ipad</key>
<array>
    <string>UIInterfaceOrientationPortrait</string>
    <string>UIInterfaceOrientationLandscapeLeft</string>
    <string>UIInterfaceOrientationPortraitUpsideDown</string>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

解决方法

我尝试了很多这方面的解决方法,但大多数都失败了.幸运的是,我找到了一个Cordova插件,可以通过JavaScript成功锁定屏幕方向.也在iPad上工作.

https://github.com/yoik/cordova-yoik-screenorientation

>添加插件:cordova插件添加net.yoik.cordova.plugins.screenorientation>使用JavaScript中的screen.lockOrientation(‘portrait-primary’)锁定屏幕.文档的设备已经触发后,请务必调用此函数.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...