我正在使用cordova 3.5.0-0.2.6(最后一个稳定版本).
我在锁定iPad设备的方向时遇到问题.
在iPhone上它正常工作,但在iPad上方向没有锁定.
我在锁定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’)锁定屏幕.文档的设备已经触发后,请务必调用此函数.