Bug: TableView with header and section not working correctly

You must Login before you can answer or comment on any questions.

If i use a TableView with a header and a section. The section has the same height like the TableView header.

how can i fix this.

thanks Marcel

var win1 = Titanium.UI.createWindow({
    title: 'Tab 1',
    backgroundColor: '#fff'
});
 
var data = [];
 
var hv = Titanium.UI.createView({
    backgroundColor: '#c3c3c3',
    height: 'auto'
});
 
 
 
 
var hlv = Titanium.UI.createLabel({
    text: 'Views',
    left: 80,
    font: {
        fontSize: 14
    },
    height: 40
});
hv.add(hlv);
 
var section = Titanium.UI.createTableViewSection({
    height: 40,
    headerView: hv
});
 
data.push(section);
 
 
 
data.push({
    title: "Row 1"
});
 
data.push({
    title: "Row 2"
});
 
 
var view4 = Ti.UI.createView({
    backgroundColor: 'black'
});
var l4 = Ti.UI.createLabel({
    text: 'View 4',
    color: '#fff',
    width: 'auto',
    height: 'auto'
});
view4.add(l4);
 
var view3 = Ti.UI.createView({
    backgroundColor: 'black'
});
var l3 = Ti.UI.createLabel({
    text: 'View 3',
    color: '#fff',
    width: 'auto',
    height: 'auto'
});
view3.add(l3);
 
var scrollView = Titanium.UI.createScrollableView({
    views: [view3, view4],
    showPagingControl: true,
    pagingControlHeight: 30,
    maxZoomScale: 2.0,
    currentPage: 1,
    height: 150,
    top: 0
});
 
 
 
 
var table = Titanium.UI.createTableView({
    headerView: scrollView,
    data: data,
});
win1.add(table);

— asked 3 years ago by Marcel Alburg
1 Comment
  • what is the difference between a header and a section in a table view? I am confused by the question? Can you post images in here?

    — commented 3 years ago by Aaron Saunders

3 Answers

Marcel has encountered (and reported) a significant bug relating to header views:

https://appcelerator.lighthouseapp.com/projects/32238/tickets/2282-tableview-with-header-and-section-not-working-correctly

https://appcelerator.lighthouseapp.com/projects/32238/tickets/1222-row-headers-are-being-pushed-down-when-there-is-a-table-header-view

It was originally reported five months ago.

There is no perfect workaround at the moment.

Hey guys, this bug is now fixed with the nightly builds of 1.6

https://appcelerator.lighthouseapp.com/projects/32238/tickets/2837-iphone-header-in-rows-inherits-height-of-table-header-view

think i saw mistakes there...

var hlv = Titanium.UI.createLabel({
    text: 'Views',
    left: 80,
    font: {
        fontSize: 14
    },
    height: 40         // here
});
hv.add(hlv);
 
var section = Titanium.UI.createTableViewSection({
    height: 40,         // and here, ergo same height?
    headerView: hv
});
and like the api doc, you should add the row to the section, then add the section to the tableview

Your Answer

Think you can help? Login to answer this question!