Skip to content

Instantly share code, notes, and snippets.

@ricardoalcocer
Created February 10, 2014 21:58
Show Gist options
  • Select an option

  • Save ricardoalcocer/8925058 to your computer and use it in GitHub Desktop.

Select an option

Save ricardoalcocer/8925058 to your computer and use it in GitHub Desktop.
Orientation changes
/*
Android:
PORTRAIT 1
LANDSCAPE 2
iOS:
PORTRAIT 1
UPSIDE_PORTRAIT 2 (iOS-only)
LANDSCAPE_LEFT 3
LANDSCAPE_RIGHT 4
Full reference: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.UI.Window-property-orientationModes
*/
// get startup orientation
$.index.addEventListener('open',function(e){
console.log("Startup Orientation: " + e.source.orientation);
alert("Startup Orientation: " + e.source.orientation);
})
//
// listen for orientation changes
Ti.Gesture.addEventListener('orientationchange', function(e) {
console.log("Orientation changed to: " + e.orientation);
alert("Orientation changed to: " + e.orientation);
});
//
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment