How to detect app start orientation
When I start the app, the splashscreen show in the correct orientation, but no the background of my main window, is there a way to detect the start orientation ?.
Thanks in advanced.
3 Answers
-
You can check the current orientation by looking at Ti.UI.orientation.
You can monitor orientation change doing something like this:
Ti.Gesture.addEventListener('orientationchange', function(e) { // Do something about orientation });
-
A workaround (aka Hack) would be to do this:
Call CurrentOrientation() instead of Ti.UI.orientation. This will return 3 if it's landscape or 1 if portrait.
The downside is you don't know which way it's facing (left/right or up/down)function CurrentOrientation() { var w = Titanium.Platform.displayCaps.platformWidth; var h = Titanium.Platform.displayCaps.platformHeight; if( w > h){ return 3; }else{ return 1; } }
-
In more recent versions of Titanium you can use the Ti.Gesture.orientation property.