Problem description
Steps to reproduce
- Use the following code:
var win1 = Titanium.UI.createWindow({
navBarHidden : false,
title : 'Test Window',
backgroundColor : 'white',
left : 0,
top : 0
});
var tableView = Titanium.UI.createTableView({
className : "session.row.class"
});
var rows = [];
for (var d = 0; d < 20; d++) {
var row = Ti.UI.createTableViewRow({
hasChild : true
});
var name_label = Ti.UI.createLabel({
text : "<b>Test title</b><br/>Testing<br/><i>This is just a label with some text</i>",
top : 5,
left : 5,
width : 300,
color : "black"
});
row.add(name_label);
rows.push(row);
}
tableView.setData(rows);
win1.add(tableView);
win1.open();
- run the code: the label is clipped;
- setting the height to 'auto' or Ti.UI.SIZE, both for the label or the row, doesn't fix the problem (label becomes invisible if row.height is Ti.UI.SIZE);
- changing rowHeight does not help as well;
- label.size.height or row.size.height seem wrong even if they are called after the table is displayed on the screen.
Hello; I have activated the instruments on the app, and logged what happens when moving between the windows. To be more clear, the app that I am testing has 3 windows, each with 2 buttons to move back and forth between them. Inside each window there is a table view: the first time the window is open, everything appears to be correct; moving 'NEXT' works too the first time; when I click 'BACK' from the second window to the first, the elements disappear. Same happens when I click 'NEXT' again, or when I do the same operation between windows 2 and 3. The windows are created in this way:
The NEXT button opens a second window with a simple win.open(); the BACK button does a win.close() on the currently open window. This is what I see with the instruments (I removed everything that is not 'layout' and added comments about my actions):
Another test that shows the same error: open the app and resize the window; also in this case, the content of the window disappear and this is what I see with the instruments:
One more thing I noticed: when the rows are created in the table view, their height is set to Ti.UI.SIZE, such as:
If I change the height to a fixed size, the problem does not occour.
Everything is working correctly. TableView's have a default rowHeight of '50', which is why they are being clipped. Changing the rowHeight property of the table view (not the table view row) to Ti.UI.SIZE works just fine. Here is how I modified your code:
BTW, a quick side note: 'auto' is converted to Ti.UI.SIZE under the hood in Mobile Web.
Hi Bryan, The code you have posted is exactly the problem I have: if I do set the rowHeight to Ti.UI.SIZE, the height is not properly calculated. Attaching a screenshot of what I see (SDK 2.1.4 or 3.0.0).
Result of the code with rowHeight set to Ti.UI.SIZE attached
An additional note: I see the same result also if I set the height of each row to Ti.UI.SIZE. Also, I do see these behaviors with different browsers: 1) Firefox 16.0.2: the screenshot is what I see as soon as the app is launched in the browser 2) Chrome 24.0.1312.14 beta: when the app runs, everything is correct; as soon as I resize the window, the rows height changes and I see the same view as in the screenshot attached. 3) Safari behaves as Firefox
Gah! It worked fine for me yesterday, briefly, but now I see the same behavior. Of course it would only work properly the one time I tested it...Yeah this is a bug in the core layout mechanism, possibly in the text measuring mechanism since it varies from browser to browser.
Pull Requests: https://github.com/appcelerator/titanium_mobile/pull/3456 https://github.com/appcelerator/titanium_mobile/pull/3457
Closing as fixed for TableView row height. Tested and verified with: Titanium Studio, build: 3.0.0.201211301903 Titanium SDK, build 3.0.0.v20121206113203 Titanium SDK, build 3.1.0.v20121206112601 Mountain Lion 10.8.2 iPod 4.3.3 Simulator 6.0 Emulator 2.2