[TIMOB-7735] iOS: Support Insert style rows in TableViews
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Medium |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2015-10-28T22:33:13.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 5.2.0 |
| Components | iOS |
| Labels | insert, listview |
| Reporter | Evan Borgstrom |
| Assignee | Hans Knöchel |
| Created | 2012-01-24T11:26:02.000+0000 |
| Updated | 2016-01-14T21:18:37.000+0000 |
Description
iOS TableView objects already support delete style rows and supporting insert style rows is trivial.
Attachments
| File | Date | Size |
|---|---|---|
| Insert-Current-Results.png | 2012-01-24T11:26:02.000+0000 | 16423 |
| Insert-Expected-Results.png | 2012-01-24T11:26:02.000+0000 | 16413 |
TC-2892 has been resolved as a duplicate of this ticket but it contains useful information and a pull request that would be useful in the context of this ticket. Blog post: http://blog.codexlabs.com/blog/2013/08/31/uitableviewcelleditingstyleinsert-is-now-a-pull-request-for-titanium-mobile/ Community pull request: https://github.com/appcelerator/titanium_mobile/pull/4636 Q&A Discussion: https://developer.appcelerator.com/question/140226/add-row-row-in-editable-tableview
it seems like the momentum on this is dead. This API is still current in iOS7 and there's no indication that iOS8 will deprecate it: https://developer.apple.com/library/ios/documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html Maybe at this point it would make more sense to just wrap the SWTableViewCell repo on github: https://github.com/CEWendel/SWTableViewCell
We will not support the insert style on the legacy
Ti.UI.TableView, but provide a solution for the usage inside theTi.UI.ListViewnow. PR: https://github.com/appcelerator/titanium_mobile/pull/7355 Demo code:var isEditing = false; var btn = Ti.UI.createButton({ title: "Edit" }); var win = Ti.UI.createWindow({ rightNavButton: btn }); var nav = Ti.UI.iOS.createNavigationWindow({window:win}); var list = Ti.UI.createListView(); var section = Ti.UI.createListSection({ items: [{ properties: { title: "Removeable Cell", canEdit: true } },{ properties: { title: "Insertable Cell", canInsert: true } }] }); list.addEventListener("delete", function(e) { Ti.API.warn("Delete"); Ti.API.warn(e); }) list.addEventListener("insert", function(e) { Ti.API.warn("Insert"); Ti.API.warn(e); e.section.insertItemsAt(e.itemIndex+1, [ { properties: { title: "New Cell" } } ], { animationStyle: Ti.UI.iPhone.RowAnimationStyle.TOP }); }); btn.addEventListener("click", function() { isEditing = !isEditing; btn.setTitle(isEditing ? "Done" : "Edit"); list.setEditing(isEditing); }) list.setSections([section]); win.add(list); nav.open();