Skip to content

Instantly share code, notes, and snippets.

@geniuswebtools
Created January 10, 2012 12:52
Show Gist options
  • Save geniuswebtools/1588927 to your computer and use it in GitHub Desktop.
Save geniuswebtools/1588927 to your computer and use it in GitHub Desktop.
Set device orientation in Titanium Studio
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