The problem
In the 3.x CI SDK, the table view rows act funny when className is used. They are not consistent and a message in the log reads:
[ERROR] TableViewRow structures for className meh does not match
Some of the symptoms are the fact the the label disappears sometimes, or the height of the row changes randomly.
To reproduce
var win = Ti.UI.createWindow();
var table = Ti.UI.createTableView();
function Row(name) {
var row = Ti.UI.createTableViewRow({className: 'meh', reusable: true, height: Ti.UI.SIZE });
row.add(Ti.UI.createLabel({text: name}));
return row;
}
function reloadOne() {
var data = [
Row('Row 1'),
Row('Row 2'),
Row('Row 3'),
Row('Row 4')
];
table.setData(data);
}
function reloadTwo() {
var data = [
Row('Row 5'),
Row('Row 6'),
Row('Row 7'),
Row('Row 8')
];
table.setData(data);
}
win.add(table);
var btnOne = Ti.UI.createButton({
title : 'click',
});
var btnTwo = Ti.UI.createButton({
title : 'click',
});
btnOne.addEventListener('click', reloadOne);
btnTwo.addEventListener('click', reloadTwo);
win.rightNavButton = btnOne;
win.leftNavButton = btnTwo;
win.open({modal:true});
Copy and paste this into app.js and run it. Click on the buttons on the navigation bar to change the table data.anges randomly.
To reproduce
var win = Ti.UI.createWindow();
var table = Ti.UI.createTableView();
function Row(name) {
var row = Ti.UI.createTableViewRow({className: 'meh', height: Ti.UI.SIZE });
row.add(Ti.UI.createLabel({text: name}));
return row;
}
function reloadOne() {
var data = [
Row('Row 1'),
Row('Row 2'),
Row('Row 3'),
Row('Row 4')
];
table.setData(data);
}
function reloadTwo() {
var data = [
Row('Row 5'),
Row('Row 6'),
Row('Row 7'),
Row('Row 8')
];
table.setData(data);
}
win.add(table);
var btnOne = Ti.UI.createButton({
title : 'click',
});
var btnTwo = Ti.UI.createButton({
title : 'click',
});
btnOne.addEventListener('click', reloadOne);
btnTwo.addEventListener('click', reloadTwo);
win.rightNavButton = btnOne;
win.leftNavButton = btnTwo;
win.open({modal:true});
Copy and paste this into app.js and run it. Click on the buttons on the navigation bar to change the table data.
PR https://github.com/appcelerator/titanium_mobile/pull/3451
3_0_X PR https://github.com/appcelerator/titanium_mobile/pull/3464
Tested with: SDK: 3.0.0 GA, 3.1.0.v20130108153753 Studio: 3.0.1.201212181159 Device: iPad2(v 5.1) No error in the console stating that TableViewrow structures for classname meh do not match