Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Bug: TableView with header and section not working correctly

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 November 5th 2010 by Marcel Alburg
  • header
  • iphone
  • section
  • tableview
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 November 6th 2010 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.

    — answered December 7th 2010 by James K
    permalink
    0 Comments
  • 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

    — answered January 31st 2011 by Pedro Enrique
    permalink
    0 Comments
  • 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

    — answered December 7th 2010 by soemarko ridwan
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.