Titanium Community Questions & Answer Archive

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

titleControl Snaps to far left initially

In a window with the following code, the titleControl should be in the middle of the title bar.

var refineButton = Ti.UI.createButton({title:'Refine', height:30, width:60}); Ti.UI.currentWindow.titleControl = refineButton;

When the window is first opened (it is a child window within a tabbed group via Ti.UI.currentTab.open), the refineButton shown above snaps to the left as the back button animates in. After the animation is complete, the titleControl element snaps to the center where it should be.

Any ideas on how to get it stay in the center where it should be an not jump around?

— asked August 23rd 2010 by Bart Lewis
0 Comments

4 Answers

  • Accepted Answer

    Suffering the same problem here, is this a bug?

    As a temporary workaround I just assign the custom title label to the view for the leftNavButton with a left offset of 160 (320/2).

    var thisWin = Ti.currentWindow;
    
    var btnView = Ti.UI.createView({
        width:320
    });
    var thisWinTitle = Ti.UI.createLabel({
        text: 'Your custom title label',
        color: '#c0c0c0',
        left:160,
        width:110,
        font:{fontSize:20,fontFamily:'HelveticaNeue'}
    });
    btnView.add(thisWinTitle);
    thisWin.leftNavButton = btnView;
    
    — answered October 12th 2010 by Jeroen Kntl
    permalink
    0 Comments
  • I "solved" this by adding a setTimeout of about half a second before adding the titleControl to the window.

    currentWin.addEventListener('focus', function(){
        setTimeout(
            function(){
                currentWin.titleControl = Ti.UI.createButton({title:'Foobar'});
            },
            500
        );
    });
    currentWin.addEventListener('blur', function(){
        currentWin.titleControl = null;
    });
    
    — answered January 18th 2011 by Bart Lewis
    permalink
    1 Comment
    • Works for me. Doesn't really look that good though. :/

      — commented June 9th 2011 by Paul Voss
  • left:130 ??

    — answered August 23rd 2010 by Dan Tamas
    permalink
    0 Comments
  • Tried that. No help.

    — answered August 24th 2010 by Bart Lewis
    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.