Go to file
2014-07-11 09:34:23 +10:00
src Fixed formatting & cleanup 2014-05-08 07:56:40 +10:00
www Fixed formatting & cleanup 2014-05-08 07:56:40 +10:00
LICENSE Initial commit 2014-05-05 23:52:14 -07:00
plugin.xml Version bump 2014-07-11 09:33:54 +10:00
README.md Readme update, added note on iOS6 raised in Issue #1 2014-07-11 09:26:09 +10:00

#cordova-yoik-screenorientation

Cordova plugin to set/lock the screen orientation in a common way for both iOS and Android.

##Install

cordova plugin add https://github.com/yoik/cordova-yoik-screenorientation

###Android

The android version is implemented via the standard activity.setRequestedOrientation as used in other screen orientation plugins

###iOS

The iOS version is a combination of the cordova JS callback window.shouldRotateToOrientation and the workaround to recheck the orientation as implemented in https://github.com/Adlotto/cordova-plugin-recheck-screen-orientation.

If you have a custom impelemntation of the window.shouldRotateToOrientation it will have to be removed for the plugin to function as expected.

####iOS6

There has been a few cases where the rotation does not change the width of the viewport

Issue #1 @dokterbob

It seems to be related to having width=device-width, height=device-height in the meta viewport (which is part of the boilerplate phonegap/cordova app). It can be solved by updating the viewport with width=device-height, height=device-width or simply removing width and height altogether.

Constants

Orientation: {
    UNSPECIFIED: "unspecified",
    LANDSCAPE: "landscape",
    PORTRAIT: "portrait",
    USER: "user",
    BEHIND: "behind",
    SENSOR: "sensor",
    NOSENSOR: "nosensor",
    SENSOR_LANDSCAPE: "sensorLandscape",
    SENSOR_PORTRAIT: "sensorPortrait",
    REVERSE_LANDSCAPE: "reverseLandscape",
    REVERSE_PORTRAIT: "reversePortrait",
    FULL_SENSOR: "fullSensor"
}

Usage

var so = cordova.plugins.screenorientation;

// with callbacks
so.setOrientation(successCallback, errorCallback, so.Orientation.PORTRAIT);

// no callbacks
so.setOrientation(so.Orientation.SENSOR_LANDSCAPE);