Titanium Community Questions & Answer Archive

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

navControl at top of screen jumps when switching tabs

I have an app with 5 tabs, each tab has its own window…
In the first page, I put a navControl at the top in the TitleControl, like this:

var navControl = Titanium.UI.createTabbedBar({
    labels:['item1','item2'],
    style:Titanium.UI.iPhone.SystemButtonStyle.BAR
});
win.setTitleControl(navControl);

However, when I tap on tab 2 to go to page 2, then tap tab 1 to go back to page 1, the navControl jumps from the top center of the screen to the top left corner of the screen.

— asked March 13th 2010 by Mark Burggraf
  • bug
  • mobile
  • navcontrol
  • settitlecontrol
0 Comments

5 Answers

  • Accepted Answer

    I am also encountering this issue as well. The TabbedBar would render correctly this first time the TabNavigator was selected. If you selected a different tab, then returned to the screen with the TabbedBar, that UI control would be rendered in the upper left of the titlebar.

    My solution was to add the following:
    win.addEventListener('focus', function()
    {
    win.titleControl = sessionDay;
    });

    win.addEventListener('blur', function()
    {
    win.titleControl = null;
    });

    sessionDay is TabbedBar Object.

    — answered March 17th 2010 by Chris Griffith
    permalink
    0 Comments
  • I tried to reproduce in KS but it worked fine. Are you setting the title control within an event (e.g., focus)? maybe you can paste in more of the code so i can take a look.

    — answered March 13th 2010 by Nolan Wright
    permalink
    0 Comments
  • Hi Nolan, I am having the same issue, here is a sample.
    Just create a blank project, and add this line to the app.js on line 50

    var tabbar = Titanium.UI.createTabbedBar({
        id:'tabbar', 
        index:0,
        labels:['7 Days', '30 Days','2010']
    });
    
    win2.setTitleControl(tabbar);
    
    — answered March 14th 2010 by Fred Anderson
    permalink
    0 Comments
  • Thanks, Chris. This works well.

    I've marked this in the code as a workaround, though. Hopefully in the next release they'll fix this and we can take this code out.

    — answered March 17th 2010 by Mark Burggraf
    permalink
    0 Comments
  • I am also encountering this issue as well. The TabbedBar would render correctly this first time the TabNavigator was selected. If you selected a different tab, then returned to the screen with the TabbedBar, that UI control would be rendered in the upper left of the titlebar.

    My solution was to add the following:
    win.addEventListener('focus', function()
    {
    win.titleControl = sessionDay;
    });

    win.addEventListener('blur', function()
    {
    win.titleControl = null;
    });

    sessionDay is TabbedBar Object.

    — answered March 18th 2010 by Chris Griffith
    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.