Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2358] TableView delete row indexing issues

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-10-14T17:14:24.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsTableView, tableViewRow
ReporterFar
AssigneeMostafizur Rahman
Created2013-10-09T23:42:21.000+0000
Updated2016-03-08T07:41:23.000+0000

Description

http://developer.appcelerator.com/question/12081/tableview-delete-row-indexing-issues

Comments

  1. Mostafizur Rahman 2013-10-10

    Hello Far, Can you please describe this issue more clearly with full test code and test case? That is can test with app.js file. Thanks
  2. Far 2013-10-10

    SDK 3.1.3 iOS 7 XCode 5
       var win = Ti.UI.createWindow({top: 20});
       
       var data = [{title: 'Apples'}, {title: 'Bananas'}, {title: 'Carrots'}, {title: 'Potatoes'}];
       var table = Ti.UI.createTableView({
       	data: data,
       	editable: true
       });
       
       table.addEventListener('click', function(e) {
       	var index = e.index;
           var row = e.row;
           
           row.hasCheck = !row.hasCheck;    
           
           Ti.API.log('index is ' + index);
       });
       
       win.add(table);
       win.open();
       
    1. Delete any row from 0 to 3 from table by standard iOS table action 2. Click row that was *after* deleted 3. You will get *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:1076 Look like invalid row returned in event. Row index is valid but no chance to get valid row by any TableView function. table.setData(table.getData()) in 'delete' event resolve this issue but it's ugly hack.
  3. Mauro Parra-Miranda 2013-10-14

    Hello, tested with iOS7, Ti 3.1.3. When you delete the rows, there is no warning nor failure. Best, Mauro
  4. Far 2013-10-15

    row.hasCheck = !row.hasCheck; not work for any row *after* deleted. You will get assertion if click last row after delete any except last.
  5. Far 2013-10-15

    Look like the problem in
       - (void)tableView:(UITableView *)ourTableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
       
    function. After delete row from section
       ...
       [[section rows] removeObjectAtIndex:[indexPath row]];
       ...
       
    there is need to fix row index (TiUITableViewRowProxy *row* property) in all rows after deleted.
  6. Mauro Parra-Miranda 2013-10-15

    Hello, I used your testcase, instructions and it's not failing. If you can provide a testcase that reproduces the issue, we can reopen this. Best, Mauro
  7. Far 2013-10-15

    Application don't crash but has wrong behavior after delete row. 1. Click last row several time. You will see that *hasCheck* property set properly. 2. Delete first row. 3. Click last row. *hasChecked* property will not change and you will get *** Assertion failure in -[UITableView _endCellAnimationsWithContext:], /SourceCache/UIKit_Sim/UIKit-2903.2/UITableView.m:1076 in console.
  8. Mauro Parra-Miranda 2013-10-15

    Hello Far, your several times is 'dozens of times per second'? Best, Mauro
  9. Far 2013-10-15

    It's not necessary. I made the video for this issue https://mega.co.nz/#!Z89zVZLJ!YSjfqgLZHa96oEKycAnG9xoS9mcL4R7cbZa9xyTMJKU
  10. Far 2013-10-18

    Watch this video (it's very short - only 14s) and reopen ticket please, so I can forget about this issue before next release, when I say: "Good work, guys!".
  11. Far 2013-11-25

    Look like fixed in master. Thx.

JSON Source