Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2991] iOS Bug: ScrollView can't carry 2 tableviews

GitHub Issuen/a
TypeBug
PriorityTrivial
StatusClosed
ResolutionInvalid
Resolution Date2011-04-15T03:34:19.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsbug, in, ios, scrollview, tableview
ReporterAlan Leard
AssigneeBlain Hamon
Created2011-04-15T03:34:19.000+0000
Updated2017-03-29T15:55:26.000+0000

Description

If a user has 2 tableViews that they want to scroll through as a Grouped tables, one and then the other. Scrollview either does not scroll, or puts one table on top of the other.

Ticket Reference: http://developer.appcelerator.com/helpdesk/view/68531">http://developer.appcelerator.com/helpdesk/view/68531

Test Code:

var win = Ti.UI.createWindow();
var view = Ti.UI.createView({});
var scrollView = Ti.UI.createScrollView({
  contentHeight:'auto',
  contentWidth:'auto', 
  top:0, 
  opacity:0.5
});

var table1 = Ti.UI.createTableView({
  style:Titanium.UI.iPhone.TableViewStyle.GROUPED, 
  top:0
  });
var table2 = Ti.UI.createTableView({
  style:Titanium.UI.iPhone.TableViewStyle.GROUPED, 
  top:0
  });

var count = 20;
var data = [];

for (var c=0;c<count;c++)
{
  var row = Ti.UI.createTableViewRow({title:"Row "+(c+1)});
  data[c] = row;
}

table1.data = data;

var inputData = [
  {title:'row 1', header:'Header 1'},
  {title:'row 2'},
  {title:'row 3'},
  {title:'row 4', header:'Header 2'},
  {title:'row 5'}
];

table2.data = inputData;

scrollView.add(table2);

scrollView.add(table1);

win.add(scrollView);

win.open();

Comments

  1. Blain Hamon 2011-04-15

    1) The code asks for the scrollable height to be '100%'. 100% of what is undefined, so it's likely 0, and rounded up to the viewable area, making the scroll view, er, scrollless.

    2) The scrollview hasn't been assigned a layout, so absolute is the default.

    3) Even if vertical layout was used, the height of the table views were not specified, and would fill up the parent container by default.

    4) The auto height of a table view is undefined because of how rows work at the OS level.

    5) Similarly, trying to lay it all out inside a scrollview is prohibitively expensive because it robs the table view of view recycling.

    6) Because of this, each table view scrolls by itself independently. That's what they do.

    7) So if you want two tableviews acting as one, use only one tableview. No scrollview needed.

       var win = Ti.UI.createWindow();
       var table = Ti.UI.createTableView({
         style:Titanium.UI.iPhone.TableViewStyle.GROUPED, 
         top:0
         });
       
       var count = 20;
       var data = [];
       
       for (var c=0;c<count;c++)
       {
         var row = Ti.UI.createTableViewRow({title:"Row "+(c+1)});
         data[c] = row;
       }
       
       data.push({title:'row 1', header:'Header 1'});
       data.push({title:'row 2'});
       data.push({title:'row 3'});
       data.push({title:'row 4', header:'Header 2'});
       data.push({title:'row 5'});
       
       table.data = data;
       
       win.add(table);
       
       win.open();
       
  2. Lee Morris 2017-03-29

    Closing ticket as invalid.

JSON Source