Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2934] iOS: setTitleControl initially positions left instead of centered, then jumps into center

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-03-25T08:40:14.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsdefect, ios, ipod
ReporterShawn Lipscomb
AssigneeMauro Parra-Miranda
Created2012-02-08T14:10:00.000+0000
Updated2016-03-08T07:47:55.000+0000

Description

Problem

When setTitleControl is used upon opening a second window, the title view initially positions itself at the far left of the nav bar, then you can see it jump to the center of the navbar. Note that this effect may not be observable on faster (newer) iPhones and cannot be seen on the Simulator...this test is done on an iPod Touch 3G.

Expected Result

The title view should not be added to the navbar until after its position (centered) has been set. So when you first see the title view, it should be centered on the nav bar.

Steps to Reproduce

drop the following app.js code into a new project

build with SDK 1.8.1

run on a 3G iPod Touch

click the "Click Me" button and watch the navbar

Testcase

var win1 = Ti.UI.createWindow({  
    title:'Main',
    backgroundColor:'gray',
    navBarHidden:false,
    barColor:'silver'
});

var ng=Ti.UI.iPhone.createNavigationGroup({window:win1});
var NavBase = Ti.UI.createWindow();
NavBase.add(ng);
NavBase.open();

var btn1=Ti.UI.createButton({title:'Click Me',
                             width:'92dp',
                             height:'44dp'});
win1.add(btn1);

btn1.addEventListener('click',SecondWind);
function SecondWind()
{
  var win2 = Ti.UI.createWindow({  
      backgroundColor:'gray',
      navBarHidden:false,
      barColor:'silver'
  });
  ng.open(win2,{animated:true});
  
  var lbl1=Ti.UI.createLabel({color:'white',
                              text:'New Title Control\nOn Two Lines',
                              height:44,
                              textAlign:'center'});
  win2.setTitleControl(lbl1);
}

Comments

  1. Shak Hossain 2012-03-25

    Please try the 1.8.2 build or later. We tested and it seems to work fine. You can download the latest build from here http://builds.appcelerator.com.s3.amazonaws.com/index.html Let me know if this issue is existing in the latest build.
  2. Shawn Lipscomb 2012-03-26

    Shak, I just tested on SDK 2.0.0.v20120325213306 and the problem still exists. Did you test on an iPod Touch 3G (see the problem description)? It is easily seen on that device.

JSON Source