Titanium JIRA Archive
Appcelerator Community (AC)

[AC-1137] iOS: Can't delete row after dynamically adding section to table view

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionDuplicate
Resolution Date2014-07-14T22:32:08.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
ReporterIvan Skugor
AssigneeMauro Parra-Miranda
Created2014-06-03T10:54:48.000+0000
Updated2016-03-08T07:37:30.000+0000

Description

After table view section is added dynamically (for example, after table view click), deleting table view row does not work. To see this issue, run this code:
Ti.UI.setBackgroundColor("#fff")

var win = Ti.UI.createWindow({
	top: 20,
	backgroundColor: "#ccc"
});

var table = Ti.UI.createTableView({
	top: 0,
	bottom: 0
});

var section = Ti.UI.createTableViewSection({
	headerView: Ti.UI.createLabel({ text: "Section" })
});

for (var i = 0; i < 10; i++) {
	section.add(Ti.UI.createTableViewRow({
		title: "Row " + (i + 1)
	}));
}

table.setData([ section ]);

var newSection;
table.addEventListener("click", function(e) {

	if (!newSection) {
		newSection = Ti.UI.createTableViewSection({
			headerView: Ti.UI.createLabel({ text: "Section 0" })
		});

		newSection.add(Ti.UI.createTableViewRow({
			title: "Bleh"
		}));

		table.insertSectionBefore(0, newSection);
	}
	else {
		var index = e.index, row;

		if (e.index < table.data[1].rows.length) {
			row = table.data[1].rows[e.index];
		}

		Ti.API.info('row');
		Ti.API.info(row && row.title);

		if (row) {
			table.deleteRow(row);
		}

	}

});

win.add(table);

win.open();
Click first time on some row in "Section" to add new section at beginning. After that, click on other rows, you'll see nothing happens. Check logs, this is error message: Assertion failure in -[UITableView _endCellAnimationsWithContext:]

Comments

  1. Shuo Liang 2014-06-10

  2. Mauro Parra-Miranda 2014-07-14

    DUP of TIMOB-17097

JSON Source