Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-11237] iOS TableView fires wrong row click event

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-10-02T20:25:57.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterPedro Enrique
AssigneeIngo Muschenetz
Created2012-10-02T20:23:46.000+0000
Updated2014-06-19T12:44:15.000+0000

Description

The problem

This issue only appears if there is a view in the rows. If there is no view in the rows, then the table functions as expected.

Repro steps

1. Press down on a table row causing it to highlight. 2. Drag the table row without releasing to view later rows. 3. Release the drag and click on a different row. 4. The row that was selected previously will be the row that receives the click event.

The code:

    var win = Ti.UI.createWindow({
        backgroundColor:'white',
    });

    var table = Ti.UI.createTableView({
        width: 320,                                                                             
        height: 255,
        separatorColor :'transparent',
        separatorStyle:Titanium.UI.iPhone.TableViewSeparatorStyle.NONE,
        style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
        backgroundColor:'transparent',
        backgroundSelectedColor:'transparent',
        focusable: false,
        top:0,
        bottom: 0
    });
    var tableRows = [];
    
    for(var i = 0; i < 6; i++) {
        var row = Titanium.UI.createTableViewRow({
            height: 60
        });
        var view = Ti.UI.createView({
            top:5, right:5, left: 5, bottom:5,
            backgroundColor: '#ccc'
        });
        
        var label = Ti.UI.createLabel({
            text:'This is row: ' + i,
            top:10,
            left:10
        });
        
        view.add(label);
        row.add(view);
        tableRows.push(row);
    }
    table.setData(tableRows);
    
    table.addEventListener('click', function(e) {
        alert(e.index);
    });
    win.add(table);
    win.open();

Comments

  1. Pedro Enrique 2012-10-02

    Tested with 3.x on CI Build and it is working properly, closing ticket for now.

JSON Source