Problem
ScrollView does not show elements when using "horizontal" layout.
Test case
To see this issue run this example:
function createContent() {
var wrapper = Ti.UI.createView({
width: Ti.UI.FILL,
height: Ti.UI.SIZE,
backgroundColor: '#f00',
horizontalWrap: true,
layout: 'horizontal'
});
var label1 = Ti.UI.createLabel({
text: 'Label 1',
width: '50%'
});
var cb1 = Ti.UI.createSwitch({
value: false
});
wrapper.add(label1);
wrapper.add(cb1);
return wrapper;
}
var win = Ti.UI.createWindow({
navBarHidden: true
});
var scrollView = Ti.UI.createScrollView({
height: Ti.UI.FILL,
width: Ti.UI.FILL,
backgroundColor: '#0f0',
layout: 'horizontal',
//layout: 'vertical',
contentHeight: Ti.UI.SIZE,
contentWidth: Ti.UI.FILL
});
win.add(scrollView);
for (var i = 0; i < 10; ++i) {
scrollView.add(createContent());
}
var table = Ti.UI.createTableView({
backgroundColor: '#00f',
height: Ti.UI.SIZE
});
scrollView.add(table);
var rows = [];
for (i = 0; i < 25; ++i) {
rows.push({ title: 'Row ' + i});
}
table.setData(rows);
win.open();
You should see only first row (Label1 and switch)
Expected result
All data should be visible, like it is on Android (run this example on Android to see how it looks)
To elaborate on the problem described above: When there is a scrollview with layout: horizontal and horizontalWrap: true, the horizontalWrap property works as expected when adding many views to the scroll view. However, if we add an item (a label, button or view for example) to the view the horizontalWrap property does not work and the views continue to be placed horizontally until they do not appear. The following is a simplified example:
If we do not add the label to the view, then horizontalWrap: true behaves as expected.
Pull pending https://github.com/appcelerator/titanium_mobile/pull/3396
Environment used for verification - Titanium SDK: 3.1.0.v20130114171802 Titanium Studio: 3.0.1.201212181159 Device : Simulator iOS 6.0, iPHONE 3G S iOS 5.0.1