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?
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;
-
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; });
-
left:130 ??
-
Tried that. No help.