Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-3356] iOS: Support TableView Auto Height (on the table itself)

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-09T18:52:00.000+0000
Affected Version/sRelease 1.6.2
Fix Version/sn/a
ComponentsiOS
Labelsdefect, ios, reported-1.6.1, rplist
ReporterDawson Toth
AssigneeEric Merriman
Created2011-04-15T03:43:09.000+0000
Updated2020-01-09T18:52:00.000+0000

Description

Problem

If you set the height of a table view to "auto", its height will end up as 0 regardless of its content.

Expected Behavior

A table view with height: 'auto' should calculate its height based on the heights of its rows.

Log

[WARN] [object TiUITableView] has an auto height value of 0, meaning this view may not be visible.

Sample Code

The following code demonstrates the problem. Note that you can set "workaround" to true to calculate the height by spinning through the rows.

var win = Ti.UI.createWindow({
    backgroundColor: '#999'
});

var rows = [
    { title: "Row 1", height: 30 },
    { title: "Row 2", height: 45 },
    { title: "Row 3", height: 15 },
    { title: "Row 4", height: 30 },
    { title: "Row 5", height: 25 }
];
var table = Titanium.UI.createTableView({
    top: 0,
    data: rows,
    height: 'auto'
});
var workaround = false;
if (workaround) {
    var height = 0;
    for (var i = 0, l = rows.length; i < l; i++) {
        height += rows[i].height;
    }
    table.height = height;
}

win.add(table);

win.open();

Associated Helpdesk Ticket

http://developer.appcelerator.com/helpdesk/view/76514">http://developer.appcelerator.com/helpdesk/view/76514

Comments

  1. tonylukasavage1 2011-04-15

    I'm having this issue as well. height:'auto' just returns zero for the height. Thanks for the workaround Dawson.

  2. Ian Tearle 2011-05-12

    I am finding that the message: [WARN] [object TiUITableView] has an auto height value of 0, meaning this view may not be visible. is reporting on Vertical layouts too, this is not just confined to table layouts. height: 'auto', is not being reported properly in: Ti.UI.createLabel Ti.UI.createView
  3. Richard Vallee 2011-10-03

    The workaround cannot work with variable height rows, which is a pretty frequent occurrence. Is there anything possible here on v1.7.2? The API itself has to know the actual height of its content, it's just a matter of making available. This is hardly trivial, at least minor.
  4. Alan Hutton 2020-01-09

    It has been decided that this issue should be closed as “Won’t do.” This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. Updating, or creating code may not reproduce the issue reported, or be a valid test case. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.

JSON Source