Skip to content

Instantly share code, notes, and snippets.

@meeech
Created February 6, 2013 18:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meeech/4724807 to your computer and use it in GitHub Desktop.
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.
//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