簡體   English   中英

PhoneGap-防止屏幕方向更改

[英]PhoneGap - Preventing Screen Orientation Changes

我使用了一個插件來嘗試在PhoneGap應用程序中鎖定屏幕方向:

科爾多瓦插件屏幕方向

在我的應用頁面中,我提取了以下代碼:

// 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.

從評論中可以看到,當我旋轉手機時,成功調用縱向主要,橫向次要等時,插件似乎已正確安裝。 問題似乎是該功能未鎖定屏幕?

任何幫助將不勝感激!

嘗試在config.xml設置此屬性。

<preference name="Orientation" value="portrait" />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM