Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

navigation in windows with no tabs

First post, please forgive the newbie questions forthcoming…
I'm working on an iPhone app and I've created the root window and button like this:

var rootWin = Titanium.UI.createWindow({
    title:'root window',
    backgroundColor:'#fff'
});

var mapBtn = Titanium.UI.createButton({
        title:"Maps"
});

mapBtn.addEventListener("click", function(e){
    var mapWin = Titanium.UI.createWindow({
        url:"maps.js",
        title:"Maps"
    });
    var closeBtn = Titanium.UI.createButton({
       title:'Close',
       style:Titanium.UI.iPhone.SystemButtonStyle.PLAIN
    });
    mapWin.open();
});

rootWin.open();

On this page I see no tabs and no navigation or title at the top of the screen. I've added buttons that open other windows and each of these windows don't have a back button or a title at the top of the screen.

I have to exit the app to get back to the rootWin

advTHANKSance!

Eric

— asked May 28th 2010 by Eric Lofland
  • iphone
  • mobile
  • navigation
0 Comments

3 Answers

  • Accepted Answer

    You have to append close button on the opened window.
    mapWin.setLeftNavButton(closeBtn);
    

    Also, you have to use tab object to launch tab, and i believe, i could be wrong, the title only shown on tabbed window.

    var tabGroup = Titanium.UI.createTabGroup();
    var Tab1 = Titanium.UI.createTab({window:rootWin,title:"Root Windows"});
    tabGroup.addTab(Tab1);
    tabGroup.open();
    
    — answered May 28th 2010 by Daniel Lim
    permalink
    0 Comments
  • Thanks for writing Daniel,

    I guess this is getting to the "root" of my question. Does the parent have to be a tabGroup? I would like to avoid tabs if possible. I can create a parent that is a window object, but it's children do not get the the navbar, I /believe/ that leftNavButton is only available when the window is the child of a tab.

    I tried with the first chunk of code and it fails for me, in fact the window doesn't even load.

    Whoops, looks like you meant:

    mapWin.LeftNavButton(closeBtn);
    
    — answered May 28th 2010 by Eric Lofland
    permalink
    0 Comments
  • There's many samples in KitchenSink you can refer to.

    You can hide tab with window.hideTabBar();

    — answered May 28th 2010 by Daniel Lim
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.