[TIMOB-12625] iOS: TableView.updateSection argument order is wrong
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2014-05-01T17:47:42.000+0000 |
| Affected Version/s | Release 3.0.0 |
| Fix Version/s | 2014 Sprint 09, 2014 Sprint 09 SDK, Release 3.3.0 |
| Components | iOS |
| Labels | module_tableview, parity, qe-closed-3.3.0, qe-testadded |
| Reporter | Arthur Evans |
| Assignee | Pedro Enrique |
| Created | 2013-02-07T22:29:44.000+0000 |
| Updated | 2016-02-25T21:57:32.000+0000 |
Description
The TableView updateSection method on iOS has the arguments in the wrong order. Unlike the other platforms (and updateRow), it expects the first argument to be a section object and the second argument to be an index.
The following code runs on Android and Mobile Web, but fails on iOS.
var win = Ti.UI.createWindow({
backgroundColor : "#eee"
});
win.open();
var section = Ti.UI.createTableViewSection({
headerView : (function() {
var view = Ti.UI.createView();
var label = Ti.UI.createLabel({
text : "Some Section"
});
view.add(label);
return view;
})()
});
var row = Ti.UI.createTableViewRow({
title : "Row"
});
section.add(row);
var section2 = Ti.UI.createTableViewSection({
headerView : (function() {
var view = Ti.UI.createView();
var label = Ti.UI.createLabel({
text : "Different Section"
});
view.add(label);
return view;
})()
});
var row2 = Ti.UI.createTableViewRow({
title : "Row 2"
});
section2.add(row2);
var table = Ti.UI.createTableView({
data: [ section ]
});
table.updateSection(0, section2);
table.addEventListener("click", function(event) {
alert("TableView Clicked");
Ti.API.debug(event.row);
});
win.add(table);
Attachments
| File | Date | Size |
|---|---|---|
| iOS Simulator Screen shot Mar 25, 2013 3.00.39 PM.png | 2013-03-25T09:31:45.000+0000 | 49842 |
Methinks:
--- a/iphone/Classes/TiUITableViewProxy.m +++ b/iphone/Classes/TiUITableViewProxy.m @@ -1084,9 +1084,9 @@ DEFINE_DEF_PROP(scrollsToTop,[NSNumber numberWithBool:YES]); } int sectionIndex; - ENSURE_INT_AT_INDEX(sectionIndex, args, 1); + ENSURE_INT_AT_INDEX(sectionIndex, args, 0); - id sectionObject = [args objectAtIndex:0]; + id sectionObject = [args objectAtIndex:1]; TiUITableViewSectionProxy * section = [self tableSectionFromArg:sectionObject]; if (section == nil) {PR: https://github.com/appcelerator/titanium_mobile/pull/5646
PR Merged
Clicking the tableview, section gets updated Verified the fix on: Device : iPhone 5c , iOS version : 7.1 SDK: 3.3.0.v20140502133323 CLI version : 3.3.0-dev OS : MAC OSX 10.9.2 Alloy: 1.4.0-dev ACS: 1.0.14 npm:1.3.2 Appcelerator Studio, build: 3.3.0.201405011408 titanium-code-processor: 1.1.1 XCode : 5.1.1 Testcase used:
var win = Ti.UI.createWindow({ backgroundColor : "#eee" }); win.open(); var section = Ti.UI.createTableViewSection({ headerView : (function() { var view = Ti.UI.createView(); var label = Ti.UI.createLabel({ text : "Some Section" }); view.add(label); return view; })() }); var row = Ti.UI.createTableViewRow({ title : "Row" }); section.add(row); var section2 = Ti.UI.createTableViewSection({ headerView : (function() { var view = Ti.UI.createView(); var label = Ti.UI.createLabel({ text : "Different Section" }); view.add(label); return view; })() }); var row2 = Ti.UI.createTableViewRow({ title : "Row 2" }); section2.add(row2); var table = Ti.UI.createTableView({ data: [ section ] }); table.addEventListener("click", function(event) { alert("TableView Clicked"); Ti.API.debug(event.row); table.updateSection(0, section2); }); win.add(table);