是否可以在钛中添加多个视图到ScrollView
?所以我要说以下内容:
var scrollView = Titanium.UI.createScrollView();
var views = [];
var view1 = Titanium.UI.createView();
views.push(view1);
var view2 = Titanium.UI.createView();
views.push(view2);
scrollView.add(views);
window.add(scrollView);
上述工作会不会?如果不是为了让它起作用需要做什么?
答案 0 :(得分:0)
根据他们的documentation,这不应该奏效。 (从未尝试过。)但你可以这样做:
views.forEach(function(view) {
scrollView.add(view);
});
答案 1 :(得分:0)
我知道这有点晚了,但我解决了这个问题的解决方案,希望它仍然有用。基本上,它涉及将scrollView的不透明度设置为0,直到您完成加载。这意味着,不是一次出现1个行,它们都同时出现,并且当程序/用户执行其他操作时,这可以在后台运行。请注意,它仅在scrollView为空时才有效 - 它不是一个很好的解决方案,可以将行添加到已经有内容的scrollView中:
var sView = Titanium.UI.createScrollView({
//Whatever properties you need for your scrollView
opacity: 0,
});
//childViews is an array of all the stuff you'd like to add to sView
childCount = childViews.length
//Add a postlayout event to the last childView - this will automatically set the opacity to 1 when the last child is loaded
childViews[childCount - 1].addEventListener('postlayout', function showScrollView(e){
this.parent.setOpacity(1);
this.removeEventListener(showScrollView);
});
//Iteratively add each view in the array to the sView
for (var x = 0; x < childCount; x++) {
sView.add(childViews[x]);
}
window.add(sView);