问题
How do we set Mobile phones to Portrait only and allow tablets to switch between portrait and landscape?
I am using Ionic/Cordova.
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" />
回答1:
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');
}
});
})
来源:https://stackoverflow.com/questions/34783909/cordova-ionic-set-portrait-only-mode-for-mobiles-and-allow-orientation-in-tabl