How to restrict app to portrait mode only in ionic for all platforms?

后端 未结 9 680
暖寄归人
暖寄归人 2020-12-23 08:37

I\'m working on Ionic/Cordova, I added this to androidManifest.xml but this didn\'t work for me and app is still showing in both ways

android:sc         


        
9条回答
  •  攒了一身酷
    2020-12-23 09:27

    Inside your angular app.js add the line screen.lockOrientation('portrait'); like shown bellow:

    an

    angular.module('app', ['ionic'])
    .run(function($ionicPlatform) {
        // LOCK ORIENTATION TO PORTRAIT.
        screen.lockOrientation('portrait');
      });
    })
    

    You will also have other code in the .run function, but the one you are interested in is the line I wrote. I haven't added the line in my code, but you may need to add the cordova-plugin-device-orientation

提交回复
热议问题