Mau*_*uro 8 orientation ipad ios 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>
Run Code Online (Sandbox Code Playgroud)
生成的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>
Run Code Online (Sandbox Code Playgroud)
我尝试了很多解决这个错误的方法,但大多数都失败了。幸运的是,我找到了一个 Cordova 插件,它可以让你通过 JavaScript 成功锁定屏幕方向。也可以在 iPad 上工作。
https://github.com/yoik/cordova-yoik-screenorientation
cordova plugin add net.yoik.cordova.plugins.screenorientationscreen.lockOrientation('portrait-primary')使用JavaScript锁定屏幕。请务必在文档deviceready触发后调用此函数。| 归档时间: |
|
| 查看次数: |
3866 次 |
| 最近记录: |