Using 1.5.1, with iOS 4.2.
I cannot for the life of me get a button to consistently populate the titleControl of windows as I move through them with the navgroup.
I've tried everything, from passing the button to the new window, to setting it before the window is opened... you can sort of see it when the window changes but then is slides away and disappears.
Does anyone have any experience combining these two elements?
1 Answer
Accepted Answer
You need to recreate the titleControl Button on each and every window. I wouldn't try to pass the button from window to window. Rather, just recreate it on each page. To keep things nice and tight, you could put the logic for the button in a separate JS file, and then include that file on every page you want the titleControl to be on.
Something like this:
File: title-control-button.js
(function(){ Ti.UI.currentWindow.addEventListener('open', function(e){ var titleButton = Ti.UI.createButton({ title:'Press Me', style:Ti.UI.iPhone.SystemButtonStyle.BORDERED }); titleButton.addEventListener('click', function(){ // Open new modal window var win = Ti.UI.createWindow({url:'new-modal-window.js'}); win.fooBar = fooBar; win.open({modal:true, navBarHidden:false}); }); Ti.UI.currentWindow.titleControl = titleButton; }); }());And then, on each page you want this button to be on, add this line to the top of the file:
Ti.include('title-control-button.js'); var fooBar = 42; // data from window to pass into modal.
Your Answer
Think you can help? Login to answer this question!