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’)锁定屏幕.文档的设备已经触发后,请务必调用函数.

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...