Screen Orientation
Cordova plugin to set/lock the screen orientation in a common way.
Requires Cordova plugin: cordova-plugin-screen-orientation
. For more info, please see the Screen Orientation plugin docs.
联系我们?

If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.
Ionic 锁定屏幕方向 Screen Orientation插件的安装(Installation)
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
Ionic 锁定屏幕方向 Screen Orientation插件支持的平台(Supported Platforms)
- Android
- iOS
- Windows
Ionic 锁定屏幕方向 Screen Orientation插件的用法(Usage)
import { ScreenOrientation } from '@ionic-native/screen-orientation/ngx';
constructor(private screenOrientation: ScreenOrientation) { }
...
// get current
console.log(this.screenOrientation.type); // logs the current orientation, example: 'landscape'
// set to landscape
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE);
// allow user rotate
this.screenOrientation.unlock();
// detect orientation changes
this.screenOrientation.onChange().subscribe(
() => {
console.log("Orientation Changed");
}
);