Created
September 15, 2011 22:43
-
-
Save jonalter/1220697 to your computer and use it in GitHub Desktop.
iOS: open window on orientation change to landscape
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Must use TiSDK 1.8.0.v20110915133349 or newer | |
| var tabGroup = Ti.UI.createTabGroup(); | |
| var win1 = Ti.UI.createWindow({ | |
| backgroundColor : 'white', | |
| orientationModes : [Ti.UI.PORTRAIT] | |
| }); | |
| var label1 = Ti.UI.createLabel({ | |
| text : 'I am a label' | |
| }); | |
| win1.add(label1); | |
| var tab1 = Ti.UI.createTab({ | |
| title : "tab1", | |
| window : win1 | |
| }); | |
| tabGroup.addTab(tab1); | |
| tabGroup.open(); | |
| var win2 = null; | |
| Ti.Gesture.addEventListener('orientationchange', function(e) { | |
| if(win2 === null) { | |
| win2 = Ti.UI.createWindow({ | |
| backgroundColor : 'white', | |
| orientationModes : [Ti.UI.LANDSCAPE_RIGHT, Ti.UI.LANDSCAPE_LEFT] | |
| }); | |
| var label2 = Ti.UI.createLabel({ | |
| text : 'I am a label' | |
| }); | |
| win2.add(label2); | |
| } | |
| if(e.orientation === Ti.UI.LANDSCAPE_RIGHT || e.orientation === Ti.UI.LANDSCAPE_LEFT) { | |
| win2.open(); | |
| } else { | |
| win2.close(); | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment