Problem Description
When you rotate a tableview that contains sections with views that do a 'FILL' for height, the refresh / redraw will leave a big white space (i.e., the row won't fill the space after rotation).
Steps to reproduce
1. Create a new mobile project (classic titanium)
2. Paste this to app.js:
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});
function doView(color) {
var view = Titanium.UI.createView({
backgroundColor : color,
});
view.width = 300;
view.height = 400;
Ti.Gesture.addEventListener('orientationchange', function() {
view.width = Ti.Gesture.isPortrait() ? 300 : 400;
view.height = Ti.Gesture.isPortrait() ? 400 : 300;
});
return view;
}
function baseView() {
var view = Ti.UI.createView({
width : '100%',
left : 0,
top : 0,
backgroundColor : 'green',
layout : 'horizontal',
height : Ti.UI.SIZE
});
Ti.Gesture.addEventListener('orientationchange', function() {
view.width = Titanium.Platform.displayCaps.platformWidth;
view.left = 0;
view.top = 0;
view.height = Ti.UI.SIZE;
});
return view;
}
var base = baseView();
var pink = doView('pink');
var blue = doView('blue');
base.add(pink);
base.add(blue);
var tableSections = [];
for (var i = 0; i < 5; i++) {
var row = Titanium.UI.createTableViewRow();
var base = baseView();
var pink = doView('pink');
var blue = doView('blue');
base.add(pink);
base.add(blue);
row.height = 'auto';
row.add(base);
var section = Titanium.UI.createTableViewSection();
section.height = Ti.UI.SIZE;
section.width = Ti.UI.FILL;
section.setHeaderTitle('Title ' + i);
section.add(row);
tableSections.push(section);
}
var table = Ti.UI.createTableView({
objName : 'table',
height: Ti.UI.SIZE
});
table.setSections(tableSections);
win.add(table);
win.open();
3. Run it in ipad simulator or ipad device.
4. You will see that a big white section is added after rotating twice the device.
Initial testings indicated that this happens on iOS 7.1 simulator, but on iOS 8.1, the white space appears momentarily, if it's scrolled slightly it will disappear.
What you really want to do is refresh the whole tableView in a single call instead of updating view piecemeal. The TableView API is really not built for this. What the developer should do is use the ListView and manipulate the defaultItemTemplate property of the listView. Attaching sample below
If you wish to do the same using TableViews you can try the code below. Note that there is a single event listener for orientationChange and all the work is done there.
Workaround in comments
Closing ticket as "Won't Fix".