【发布时间】:2016-07-23 18:45:48
【问题描述】:
我使用了一个插件来尝试在我的 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.
正如您从 cmets 中看到的那样,插件似乎已正确安装,因为我在旋转手机时成功调用了纵向主、横向辅助等。问题似乎是该功能没有锁定屏幕?
任何帮助将不胜感激!
【问题讨论】:
-
您想在整个应用中锁定方向吗?
-
@ShashankAgrawal - 是的,我希望锁定整个应用程序。根据下面的评论,我尝试通过 avi config.xml 文件执行此操作,但没有运气。
标签: android ios cordova phonegap-plugins phonegap-desktop-app