{ "id": "97627", "key": "TIMOB-10172", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [], "resolution": null, "resolutiondate": null, "created": "2012-07-19T09:35:57.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "api", "community" ], "versions": [ { "id": "13271", "description": "Release 2.1.0", "name": "Release 2.1.0", "archived": false, "released": true, "releaseDate": "2012-06-29" }, { "id": "14162", "description": "Release 3.1.0", "name": "Release 3.1.0", "archived": true, "released": true, "releaseDate": "2013-04-16" } ], "issuelinks": [], "assignee": null, "updated": "2018-02-28T20:03:39.000+0000", "status": { "description": "The issue is open and ready for the assignee to start work on it.", "name": "Open", "id": "1", "statusCategory": { "id": 2, "key": "new", "colorName": "blue-gray", "name": "To Do" } }, "components": [ { "id": "10206", "name": "iOS", "description": "iOS Platform" } ], "description": "Problem:\r\n========\r\nTi.UI.TableView.insertRowBefore does not work after delete a row\r\n\r\nReproduction:\r\n=============\r\n- insert 2 rows by pressing '+' (list: 2, 1)\r\n- swipe first row to delete '2' item (list: 1)\r\n- '+' will not work more (insertRowBefore does not work)\r\n\r\nSample Code (app.js):\r\n=====================\r\n\r\nvar self = Ti.UI.createWindow({\tmodal: true });\r\nvar tableView = Ti.UI.createTableView({ editable: true});\r\nself.add(tableView);\r\nvar id = 0;\r\nvar addButton = Ti.UI.createButton({ systemButton: Ti.UI.iPhone.SystemButton.ADD });\r\naddButton.addEventListener('click', function() {\r\n\tvar tableRow = Ti.UI.createTableViewRow({ title: '' + ++id });\t\t\r\n\ttableView.data.length ? tableView.insertRowBefore(0, tableRow) : tableView.appendRow(tableRow);\r\n});\r\nself.rightNavButton = addButton;\r\nself.open();\r\n", "attachment": [], "flagged": false, "summary": "iOS: Ti.UI.TableView.insertRowBefore does not work after delete a row", "creator": { "name": "bymer", "key": "bymer", "displayName": "bymer", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "bymer", "key": "bymer", "displayName": "bymer", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "Titanium Studio, build: 2.1.0\r\niOS 5.1+\r\n", "comment": { "comments": [ { "id": "246832", "author": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Issue reproduces \n\nTested with\n\nTitanium Studio, build: 3.0.1.201212181159\nTitanium SDK version: 3.1.0 \nTitanium SDK version: 3.0.2 \niOS iPhone Simulator: iOS SDK version: 6.0", "updateAuthor": { "name": "shameerj", "key": "shameerj", "displayName": "Shameer Jan", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-04-10T08:55:46.000+0000", "updated": "2013-04-10T08:55:46.000+0000" }, { "id": "254120", "author": { "name": "rococo", "key": "rococo", "displayName": "Kaos Arts", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Related issue: if you add 3+ rows then delete the first one, next insertRowBefore(0, ...) will add it into the index 1 location instead of index 0. If you delete the first two insertRowBefore(0, ..) will add it to the index 2 location, and so forth. This seems specific to the swipe delete gesture, doesn't repro for programmatic deletions.", "updateAuthor": { "name": "rococo", "key": "rococo", "displayName": "Kaos Arts", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-27T20:03:22.000+0000", "updated": "2013-05-27T20:03:22.000+0000" }, { "id": "254125", "author": { "name": "rococo", "key": "rococo", "displayName": "Kaos Arts", "active": true, "timeZone": "America/Los_Angeles" }, "body": "FWIW the same problem exists with insertRowAfter. The bug is related to handling of delete row gestures.", "updateAuthor": { "name": "rococo", "key": "rococo", "displayName": "Kaos Arts", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-27T20:20:51.000+0000", "updated": "2013-05-27T20:20:51.000+0000" }, { "id": "254150", "author": { "name": "rococo", "key": "rococo", "displayName": "Kaos Arts", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Patch that works with 3.0.2GA:\r\n\r\n--- ./aws_example/build/iphone/Classes/TiUITableView.m 2013-03-13 23:04:41.000000000 -0700\r\n+++ ./test/build/iphone/Classes/TiUITableView.m 2013-05-27 17:22:21.000000000 -0700\r\n@@ -1880,26 +1880,27 @@ return result; \\\r\n {\r\n TiUITableViewSectionProxy *section = [self sectionForIndex:[indexPath section]];\r\n NSInteger index = [self indexForIndexPath:indexPath];\r\n UITableView *table = [self tableView];\r\n NSIndexPath *path = [self indexPathFromInt:index];\r\n \r\n // note, trigger action before the update since on the last delete it will be gone..\r\n [self triggerActionForIndexPath:indexPath fromPath:nil tableView:ourTableView wasAccessory:NO search:NO name:@\"delete\"];\r\n- \r\n- [[section rows] removeObjectAtIndex:[indexPath row]];\r\n+\r\n+ [table beginUpdates];\r\n+ TiUITableViewRowProxy* row = [self rowForIndexPath:indexPath];\r\n+ [self deleteRow:row];\r\n \r\n // If the section is empty, we want to remove it as well.\r\n BOOL emptySection = ([[section rows] count] == 0);\r\n if (emptySection) {\r\n [[(TiUITableViewProxy *)[self proxy] internalSections] removeObjectAtIndex:[indexPath section]];\r\n }\r\n \r\n- [table beginUpdates];\r\n if (emptySection)\r\n {\r\n NSIndexSet * thisSectionSet = [NSIndexSet indexSetWithIndex:[indexPath section]];\r\n if([(TiUITableViewProxy *)[self proxy] sectionCount] > 0)\r\n {\r\n [table deleteSections:thisSectionSet withRowAnimation:UITableViewRowAnimationFade];\r\n }\r\n else //There always must be at least one section. So instead, we have it reload to clear out the header and footer, etc.\r\n", "updateAuthor": { "name": "rococo", "key": "rococo", "displayName": "Kaos Arts", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-05-28T00:27:16.000+0000", "updated": "2013-05-28T00:27:16.000+0000" }, { "id": "370080", "author": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "body": "Any chance this will be fixed?... This is still a problem with SDK 5.0", "updateAuthor": { "name": "thomas.neerup@eg.dk", "key": "thomas.neerup@eg.dk", "displayName": "Thomas Neerup", "active": true, "timeZone": "Europe/Copenhagen" }, "created": "2015-11-12T11:33:26.000+0000", "updated": "2015-11-12T11:33:26.000+0000" } ], "maxResults": 5, "total": 5, "startAt": 0 } } }