Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12625] iOS: TableView.updateSection argument order is wrong

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-05-01T17:47:42.000+0000
Affected Version/sRelease 3.0.0
Fix Version/s2014 Sprint 09, 2014 Sprint 09 SDK, Release 3.3.0
ComponentsiOS
Labelsmodule_tableview, parity, qe-closed-3.3.0, qe-testadded
ReporterArthur Evans
AssigneePedro Enrique
Created2013-02-07T22:29:44.000+0000
Updated2016-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

FileDateSize
iOS Simulator Screen shot Mar 25, 2013 3.00.39 PM.png2013-03-25T09:31:45.000+000049842

Comments

  1. Arthur Evans 2013-02-07

    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) {
       
  2. Pedro Enrique 2014-04-25

    PR: https://github.com/appcelerator/titanium_mobile/pull/5646
  3. Vishal Duggal 2014-05-01

    PR Merged
  4. Paras Mishra 2014-05-05

    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);
       

JSON Source