Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2282] iOS: TableView with header and section not working correctly

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-07-20T14:36:33.000+0000
Affected Version/sRelease 1.6.0
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterMarcel Alburg
AssigneeNeeraj Gupta
Created2011-04-15T03:15:35.000+0000
Updated2017-03-09T22:18:11.000+0000

Description

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);

Attachments

FileDateSize
iOS Simulator Screen shot Jul 20, 2012 2.34.42 PM.png2012-07-20T14:36:18.000+00009704

Comments

  1. Marcel Alburg 2011-04-15

    Hello,

    we found the problem

    In File: ./Classes/TiUITableView.m

    In Function: - (CGFloat)tableView:(UITableView *)ourTableView heightForHeaderInSection:(NSInteger)section

    Ca. Line 1871

    if ([tableview tableHeaderView]!=nil && searchField == nil) {

       size+=[tableview tableHeaderView].frame.size.height;
       

    }

    if i commed out the lines, it works.

    If this a bug ?
    Thanks

    Marcel

  2. James K 2011-04-15

    Unfortunately this fix seems to prevent the section headers in a plain table view from 'floating' over the rows as you scroll.

    Would be very interested in a solution.

  3. Stephen Tramer 2011-04-15

    Possibly fixed, we'll have to see.

  4. Vishal Duggal 2012-07-20

    See attached screenshot
  5. Neeraj Gupta 2012-07-21

    Does not reproduce with release 2.1.0.
  6. Lee Morris 2017-03-09

    Closing ticket as the issue cannot be reproduced.

JSON Source