Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25337] iOS: Custom ListItem does not respect default row-height of 43px, sizing instead (regression)

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionInvalid
Resolution Date2017-10-10T08:34:03.000+0000
Affected Version/sRelease 6.2.2, Release 6.2.0, Release 6.2.1
Fix Version/sn/a
ComponentsiOS
Labelsconsider-6.2.3, ios, listview, regression
ReporterHans Knöchel
AssigneeVijay Singh
Created2017-09-24T09:01:46.000+0000
Updated2018-08-06T17:37:00.000+0000

Description

I noticed that custom item-templates will size by default on 6.2.0. It's no blocker as the developer can just set a height of 43 which is the default cell-height, but ideally, we should address that in the height-calculation of the TiUIListView.m already. *EDIT*: It's actually a regression from TIMOB-23436. Reverting the change resolves this issue, so we need to find a better way to fix TIMOB-23436. Test-Case:
var win = Ti.UI.createWindow({backgroundColor: 'white'});

var myTemplate = {
    childTemplates: [
        {                            // Title 
            type: 'Ti.UI.Label',     // Use a label for the title 
            bindId: 'info',          // Maps to a custom info property of the item data
            properties: {            // Sets the label properties
                color: 'red',
            }
        }
    ]
};

var listView = Ti.UI.createListView({
    templates: { 'template': myTemplate },
    defaultItemTemplate: 'template'
});
var sections = [];

var fruitSection = Ti.UI.createListSection({ headerTitle: 'Fruits / Frutas'});
var fruitDataSet = [
    { info: {text: 'Apple'}},
    { info: {text: 'Banana'}}
];
fruitSection.setItems(fruitDataSet);
sections.push(fruitSection);
listView.setSections(sections);

win.add(listView);
win.open();

Comments

  1. Vijay Singh 2017-10-05

    In this it is calculating height of label and accordingly it is setting height of cell if height of cell is not set explicitly. I think it is right. Lets take following test case -
       var win = Ti.UI.createWindow({
           backgroundColor: '#fff'
       });
       var myTemplate = {
               childTemplates: [{
                   type: 'Ti.UI.ImageView',
                   bindId: 'pic'
               }]
       };
       var list = Ti.UI.createListView({
           templates:{'template':myTemplate},
           defaultItemTemplate: 'template',
       });
       var sections = [];
       var imgSection = Ti.UI.createListSection({headerTitle:'Test Image Template'});
       var listItems = [];
       for (var i = 0; i < 5; i++) {
           listItems.push({pic:
               {image : 'image.JPG'}
           });
       }
       imgSection.setItems(listItems);
       sections.push(imgSection);
       list.setSections(sections);
       win.add(list);
       win.open();
       
    In this example image is getting set in cell. If we are not sure how much size we should give the cell, in this case it will calculate the height according to image and will return cell height. If we return default cell-height, 43, image will not fit properly in cell. There is always an option for developer to set height of cell . I think we can make this issue 'invalid'. [~emerriman]/[~hknoechel] thought ?
  2. Eric Merriman 2018-08-06

    Closing as invalid. If incorrect, please reopen.

JSON Source