PhoneGap - 防止屏幕方向变化

时间:2016-07-23 18:45:49

标签: android ios cordova phonegap-plugins phonegap-desktop-app

我使用了一个插件尝试锁定我的PhoneGap应用中的屏幕方向:

cordova-plugin-screen-orientation

在我的应用页面中,我有以下代码提取:

// Once DOM is loaded...
$(document).on('pagecreate', function() {

window.screen.lockOrientation('portrait');                  // Seems to set variable but not LOCK screen?

var orient = screen.orientation;                            // Works
alert(orient);                                              // Works

window.addEventListener("orientationchange", function(){    // Works
    alert(screen.orientation); // e.g. portrait             // Works
});                                      

... Other code etc.

正如您从评论中看到的那样,插件似乎安装正确,因为我在旋转手机时成功调用了纵向 - 主要,横向 - 辅助等。问题似乎是功能是不是锁定屏幕?

任何帮助都会非常感激!

1 个答案:

答案 0 :(得分:3)

尝试在config.xml

中设置此属性
<preference name="Orientation" value="portrait" />
相关问题