Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8698] iOS: TableViewRow auto height in grouped styled TableView

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-01-10T18:04:53.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsapi
ReporterAdam Wallner
AssigneeUnknown
Created2012-04-12T03:00:53.000+0000
Updated2020-01-10T18:04:53.000+0000

Description

Problem

When I create a TableView with style=Ti.UI.iPhone.TableViewStyle.GROUPED and make rows' height to "auto", the calculated height is bad.

Test case

Ti.UI.setBackgroundColor('#000');

var win = Ti.UI.createWindow({
	title: 'Win',
	fullscreen: true
});

var section = Ti.UI.createTableViewSection();
section.headerTitle = "Test";

var row1 = Ti.UI.createTableViewRow({
	hasChild: true,
	height: 'auto'
});
var lbl1 = Ti.UI.createLabel({
	text: '11111 11111 11111 11111 11111111 1111111 11111111111 111',
	width: '100%',
	height: 'auto'
})
row1.add(lbl1);
section.add(row1);

var row2 = Ti.UI.createTableViewRow({
	hasChild: true,
	height: 'auto'
});
var lbl2 = Ti.UI.createLabel({
	text: '222222222 222222 222222 22222222222 22222 2222222222 222',
	width: '100%',
	height: 'auto'
})
row2.add(lbl2);
section.add(row2);

var tv = Ti.UI.createTableView({
	width: '100%',
	height: '100%',
	style: Ti.UI.iPhone.TableViewStyle.GROUPED,
	data: [section]
});
win.add(tv);

win.open();

Cause

The grouped tableview has padding left and right, the algorithm which calculate the height does not take this into.

Solution

I've made a change in TiUITableViewRowProxy.m in sizeWidthForDecorations:forceResizing method. Added this code at the end. This solves the problem.
if ([[table tableView] style]==UITableViewStyleGrouped) {
    width -= ([TiUtils isIPad]==NO) ? 20 : 60;
}

Comments

  1. Mitchell Amihod 2012-05-10

    This still exists in 2.x. Any chance this will get added?
  2. Alan Hutton 2020-01-10

    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. 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