Created
January 10, 2012 12:52
-
-
Save geniuswebtools/1588927 to your computer and use it in GitHub Desktop.
Set device orientation in Titanium Studio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
isAndroid = (Ti.Platform.osname == 'android') ? true : false; // Detect Android OS | |
Ti.UI.orientation = Ti.UI.PORTRAIT; // Force portrait view | |
if(isAndroid === true)// Force orientation to maintain portrait | |
{ | |
Ti.Gesture.addEventListener('orientationchange', function(e) | |
{ | |
Ti.Android.currentActivity.setRequestedOrientation(Ti.Android.SCREEN_ORIENTATION_PORTRAIT); | |
}); | |
} // end if | |
// Set and keep orientation after creating a Window | |
newWindow = Titanium.UI.createWindow( | |
{ | |
// other arguments | |
orientationModes : [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT] // if this doesn't work ... | |
}) | |
newWindow.orientationModes = [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT]; // ... this will |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment