Screen Orientation

Improve this doc

$ ionic plugin add cordova-plugin-screen-orientation

Repo: https://github.com/apache/cordova-plugin-screen-orientation

Cordova plugin to set/lock the screen orientation in a common way for iOS, Android, WP8 and Blackberry 10. This plugin is based on an early version of Screen Orientation API so the api does not currently match the current spec.

Requires Cordova plugin: cordova-plugin-screen-orientation. For more info, please see the Screen Orientation plugin docs.

Supported platforms

Usage

import { ScreenOrientation } from 'ionic-native';


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

// allow user rotate
ScreenOrientation.unlockOrientation();

Static Members

lockOrientation(orientation)

Lock the orientation to the passed value. See below for accepted values

Param Type Details
orientation string

The orientation which should be locked. Accepted values see table below.

unlockOrientation()

Unlock and allow all orientations.

orientation

Get the current orientation of the device.

Advanced

Accepted orientation values:

Value Description
portrait-primary The orientation is in the primary portrait mode.
portrait-secondary The orientation is in the secondary portrait mode.
landscape-primary The orientation is in the primary landscape mode.
landscape-secondary The orientation is in the secondary landscape mode.
portrait The orientation is either portrait-primary or portrait-secondary (sensor).
landscape The orientation is either landscape-primary or landscape-secondary (sensor).

API

Native

General