Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-650] when changing from auto to fix height label does not display properly

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:53:48.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.2.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:33:45.000+0000
Updated2011-04-17T01:53:48.000+0000

Description

run this code in a app.js and click on any of the labels to toggle their height:

var win = Titanium.UI.createWindow();

var y = 20;

var scrollView = Titanium.UI.createScrollView({

contentWidth:'auto',
contentHeight:'auto'

}); scrollView.layout = 'vertical';

function addText(txt)
{

label = Ti.UI.createLabel({
    width:290,
    height:'auto',
    text:txt,
    font:{fontSize:16}
});
view = Ti.UI.createView({
    width:310,
    height:'auto',
    backgroundColor:'#22FFFF',
    borderWidth:1,
    top:5,
    bottom:5
});
view.add(label);

scrollView.add(view);

label.addEventListener('click',function(e) {
    if (e.source.height == 38)
    {
        e.source.height = 'auto';
    }
    else 
    {
        e.source.height = 38;
    }
});

}

addText("1. A b c d e f g h i j k l m n o p q r s t u v w x y z aa bb cc dd ee ff gg hh ii jj kk ll mm nn oo pp qq rr ss tt uu vv ww xx yy zz. ");
addText("2. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. ");
addText("3. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. ");
addText("4. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. ");
addText("5. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. Now is the time for all good men to come to the aid of their country. ");

win.add(scrollView);

win.open()

Comments

  1. Stephen Tramer 2011-04-15

    Bug doesn't affect just autoresize; it affects going from any larger size to a smaller size. In this case, text appears to be truncated to start at height 38 of the original label contents (at font size 16, this means it always starts at the second line), and then proceed for another 38.

  2. Stephen Tramer 2011-04-15

    Slight correction - the text is drawn based on the new center point from the resize. So from the center point we are drawn (width / 2) on either side, and (height/2) above/below the center point. Has to be a way to change this.

  3. Stephen Tramer 2011-04-15

    This one was sneaky. The view wasn't being redrawn on resize, and in fact this bug may affect other views which rely on the same behavior. The solution is to set

    view.contentMode = UIViewContentModeRedraw

    Which forces a redraw whenever the bounds/frame/center are changed. It's also worth noting that setting a view's bounds/frame/center also resets these other values, so a call to more than one method may not be necessary (especially since it triggers multiple redraws for UILabels now).

  4. Jeff Haynie 2011-04-15

    (from [02900cc0c0d03deacc1d021bdd1e27df94a1b348]) Closes #650: Set contentMode to redraw on boundary change. http://github.com/appcelerator/titanium_mobile/commit/02900cc0c0d03deacc1d021bdd1e27df94a1b348"> http://github.com/appcelerator/titanium_mobile/commit/02900cc0c0d03...

JSON Source