Created
February 6, 2013 18:49
-
-
Save meeech/4724807 to your computer and use it in GitHub Desktop.
work around the fact you can't show/hide buttons in a toolbar on ios w/ titanium. So this manages the toolbar for portrait/landscape mode of the detail window in a split view.
This file contains 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
//So, grab the toolbar items. | |
//Its set up for portrait by default | |
var tbButtons = $.toolbar.items | |
, showMasterViewButton = tbButtons[0] //cache a copy | |
; | |
//For first run if launched in landscape mode | |
if(Ti.Gesture.isLandscape()) { | |
tbButtons.shift(); | |
$.toolbar.items = tbButtons; | |
} | |
Ti.Gesture.addEventListener('orientationchange', function(e) { | |
if(Ti.Gesture.isLandscape()) { | |
Ti.API.warn('orientationchange ---> landscape'); | |
tbButtons.shift(); | |
} else { | |
Ti.API.warn('orientationchange ---> portrait'); | |
tbButtons.unshift(showMasterViewButton); | |
} | |
$.toolbar.items = tbButtons; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment