I'm using the below snippet to change the layout of the iPad in a splitveiw. It works fine on the simulator and on a older iPad but on the iPad 2 when I have it on landscape facing at me and then slightly tilt it forward/backwards the detailview changes back to the portrait orientation dimensions but the masterview is ok. It's really annoying me. Can anyone help?
function getOrientation(o) { switch (o) { case Titanium.UI.PORTRAIT: return 'portrait'; case Titanium.UI.UPSIDE_PORTRAIT: return 'portrait'; case Titanium.UI.LANDSCAPE_LEFT: return 'landscape'; case Titanium.UI.LANDSCAPE_RIGHT: return 'landscape'; } } Ti.Gesture.addEventListener('orientationchange',function(e){ var orientation = getOrientation(e.orientation); if (orientation == 'portrait') { //do something } else if (orientation == 'landscape') { //do something } });
2 Answers
I had the same problem, and ended up using these:
Ti.Gesture.addEventListener('orientationchange', function(e){ if (e.orientation == Titanium.UI.PORTRAIT || e.orientation == Titanium.UI.UPSIDE_PORTRAIT) { // do something } else if (e.orientation == Titanium.UI.LANDSCAPE_LEFT || e.orientation == Titanium.UI.LANDSCAPE_RIGHT) { // do something } });
did you try just using the property Ti.Gesture.isLandscape()
Your Answer
Think you can help? Login to answer this question!