Cordova/Ionic - 为手机设置仅纵向模式并允许在平板电脑中定位

标签 cordova ionic android-orientation device-orientation

我们如何将手机设置为仅纵向并允许平板在纵向和横向之间切换?

我正在使用 ionic / Cordova 。

目前我已配置为使用以下属性在 config.xml 中将应用程序设置为纵向模式

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

最佳答案

您可以使用 isTablet pluginscreen orientation plugin 一起使用, 就像是:

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.isTablet){
        screen.unlockOrientation();
    }else{
        screen.lockOrientation('portrait');
    } 
  });
})

关于Cordova/Ionic - 为手机设置仅纵向模式并允许在平板电脑中定位,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34783909/

相关文章:

ionic-framework - 当键盘在 Android 上关闭时显示白色背景

安卓 : Custom ListView Disappear After Orientation Change

javascript - Phonegap - 自动重定向到页面

android - 在 Android 模拟器中使用我安装的应用程序获取白屏(但在浏览器中有效)

angularjs - 在哪里安装带有 Laravel 后端的 Ionic?

android - 旋转手机时信息消失

Android 将方向锁定为起始方向

cordova - 在页面之间导航时闪烁

ios - 使用Cordova在iTunes中打开应用