Cordova / Ionic - 为手机设置仅限纵向模式,并允许在平板电脑中定位 [英] Cordova/Ionic - Set Portrait Only Mode for Mobiles and allow Orientation in Tablets
本文介绍了Cordova / Ionic - 为手机设置仅限纵向模式,并允许在平板电脑中定位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们如何将手机设置为只限肖像并允许平板电脑在纵向和横向之间切换?
How do we set Mobile phones to Portrait only and allow tablets to switch between portrait and landscape?
我使用的是Ionic / Cordova。
I am using Ionic/Cordova.
目前我已配置使用以下属性将应用程序设置为config.xml中的纵向模式
Currently I have configured to set the app to be in portrait mode in config.xml using the following property
<preference name="orientation" value="portrait" />
推荐答案
您可以使用 isTablet插件与屏幕方向插件,类似于:
You could use isTablet plugin in conjunction with screen orientation plugin, something like:
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
if(window.isTablet){
screen.unlockOrientation();
}else{
screen.lockOrientation('portrait');
}
});
})
这篇关于Cordova / Ionic - 为手机设置仅限纵向模式,并允许在平板电脑中定位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文