Screen Orientation lock in specific states


#1

Is there a way to lock specific screens to a specific orientation for Android?

I only found ways to set landscape/portrait mode for the whole application. I just need it for one screen.


Issue with iPad app in Landscape mode
Landscape only displays half the pages on iOS 8
Lock orientation of some html pages in ionic
#2

Yes, you can do it easy.

First you will need to use Cordova net.yoik.cordova.plugins.screenorientation plugin.

You can easily lock/unlock screen orientation using it.

// set to either landscape
screen.lockOrientation('landscape');

// allow user rotate
screen.unlockOrientation();

Next, to do it only on selected pages, use this code inside an appropriate page controller:

$scope.$on('$ionicView.beforeEnter', function(){
    screen.lockOrientation('landscape');
});

If executed in a right controller this code will trigger orientation lock before the view becomes visible.

Read this if you want to find out more: http://www.gajotres.net/changing-locking-screen-orientation-in-ionic-application/


#3

Hi, i’m also have this lock screen issue, how to integrate this plugin into angular apps?


#4

This is not working for me. following is my setup

Cordova CLI: 6.0.0
Gulp version: CLI version 3.9.0
Gulp local: Local version 3.9.0
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.2
ios-sim version: 5.0.3
OS: Mac OS X El Capitan
Node Version: v5.1.0
Xcode version: Xcode 7.2.1 Build version 7C1002

Can you suggest please!