Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9979] iOS: Longpress event on TableView is not reliable.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-08-09T03:43:53.000+0000
Affected Version/sRelease 3.0.0
Fix Version/sSprint 2012-15 API, Release 3.0.0
ComponentsiOS
Labelsmodule_tableview, qe-testadded
ReporterSabil Rahim
AssigneeSabil Rahim
Created2012-07-16T17:12:35.000+0000
Updated2014-06-19T12:42:59.000+0000

Description

The "longpress" event is inconsistent on iOS. if you don't see the issue the first time, keep running it again , within 4 to 5 times you should be able see the issue.

Steps to Reproduce.

Copy the following code into app.js and run the app.
var win = Ti.UI.createWindow();
  
var tableData = []
var s = 0;
var nRow = 0;
for(var i = 0; i < 100; i++){
    var createNewSection = (i + 1) % 10 == 9 || i == 0 ? true : false;
    createNewSection ? nRow = 1 : nRow++;
    tableData.push({
        title:'Row #' + nRow + ' Index #' + i + ' Section #' + s,
        customProp:'Hello World! #' + i,
        header: createNewSection ? 'Section #' + s++ : null
    });
}
  
var table = Ti.UI.createTableView({
    data: tableData
});
  
win.add(table);
  
table.addEventListener('longpress', function(e){
    Ti.API.info('Section:    ' + e.section);
    Ti.API.info('Row:        ' + e.row);
    Ti.API.info('Row Data:   ' + e.rowData);
    Ti.API.info('Index:      ' + e.index);
    Ti.API.info('customProp: ' + e.rowData.customProp);
});
  
win.open();

Actual Result

[INFO] Section:    undefined [INFO] Row:        undefined [INFO] Row Data:   undefined [INFO] Index:      undefined [WARN] Exception in event callback. { line = 27; message = "'undefined' is not an object (evaluating 'e.rowData.customProp')"; name = TypeError; sourceId = 265738656; sourceURL = "file://localhost/Users/srahim/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/CF8F7932-C2A4-477A-83DA-1E58F7FBC404/Titanium.app/app.js"; }

Expected Result(or similar to this)

[INFO] Section:    [object TiUITableViewSection] [INFO] Row:        [object TiUITableViewRow] [INFO] Row Data:   [object TiUITableViewRow] [INFO] Index:      6 [INFO] customProp: Hello World! #6

Comments

  1. Vishal Duggal 2012-07-17

    Fixed by PR #2579 against master https://github.com/appcelerator/titanium_mobile/pull/2579
  2. Neha Chhabra 2012-08-09

    Reopening to update labels
  3. Satyam Sekhri 2012-08-24

    Exists on: Titanium Studio: 2.1.2.201208201549 Titanium SDK: 2.1.2.v20120821160113 Device: iPad3(v5.1) Fixed on SDK: 2.2.0

JSON Source