2012年4月4日 星期三

[Titanium] Orientation Change detection

To detect orientation change:

Ti.Gesture.addEventListener('orientationchange', function(e){

if(e.orientation==Titanium.UI.PORTRAIT || e.orientationo==Titanium.UI.UPSIDE_PORTRAIT){
//portrait setting
}else if(e.orientation==Titanium.UI.LANDSCAPE_LEFT ||       e.orientation==Titanium.UI.LANDSCAPE_RIGHT){
//landscape setting
}
});

Orientation Value

Titanium.UI.PORTRAIT = 1
Titanium.UI.UPSIDE_PORTRAIT = 2
Titanium.UI.LANDSCAPE_RIGHT = 3
Titanium.UI.LANDSCAPE_LEFT = 4
NOTE: Value of 0 & 5 are Shakes

To obtain current screen size:

Titanium.Platform.displayCaps.platformWidth,
Titanium.Platform.displayCaps.platformHeight,

沒有留言:

張貼留言