0

I found this thread that will lock it for every device How to restrict app to portrait mode only in ionic for all platforms? but what I am looking to do is allow screen rotation on tablets, but not phones.

I was hoping this would be something I could setup in the config.xml, but I am thinking I am going to need something more like this https://ionicframework.com/docs/native/screen-orientation/ and do it programmatically unless I am missing something. Any ideas?

1 Answer 1

2

You can use import { Platform} from 'ionic-angular'; for check device and import { ScreenOrientation } from '@ionic-native/screen-orientation'; for rotate your screen.

constructor(private navCtrl: NavController, private plt: Platform, private screen: ScreenOrientation) {
    if (this.plt.is('tablet')) {
      if (this.screen.type === 'portrait-primary') {
        this.screen.lock(this.screen.ORIENTATIONS.LANDSCAPE);
      }
    }
  }

This code with check if device is tablet and check if screen is portrait then it will automatically rotate your screen to landscape mode.

Not the answer you're looking for? Browse other questions tagged or ask your own question.