使用5.1.2迭代生成的按钮不起作用。 复制我的代码并使用带有5.1.1和5.1.2的iPad模拟器进行尝试。 你会看到差异。使用5.1.2,在更好的情况下点火第一和第二按钮。
static const int array[] = { 1, 2, 3, 6 };
int size = (int)std::distance(std::begin(array), std::end(array))+1;
答案 0 :(得分:0)
似乎缺乏记忆力。使用sdk 5.1.2我在没有LiveView的iPad2模拟器上尝试新项目中的代码,它工作正常但不在我的真实项目中。现在,在新项目中,我尝试了90次迭代,点击前18个按钮,5.1.1在所有按钮中工作正常。
var win = Ti.UI.createWindow({backgroundColor: 'white'});
var data = [];
var c =1;
for(var i=1; i<=90; i++){
if (c == 1) {
var page_view = Ti.UI.createView({
layout: 'horizontal'
});
}
var view = Ti.UI.createView({
backgroundColor: 'green',
width : 250,
left: 5
});
var button = Ti.UI.createButton({
bottom : 10,
left : 10,
right : 10,
height : 40,
color : '#fff',
backgroundColor : 'red',
title : "click",
ids: i
});
view.add(button);
button.addEventListener('click', function(e) {
Ti.API.info('button: ' + e.source.ids);
});
page_view.add(view);
if (c % 3 == 0) {
data.push(page_view);
c = 1;
} else {
c++;
if (i == 90) {
data.push(page_view);
}
}
}
var scroll_view = Ti.UI.createScrollableView({
showPagingControl : true,
top : 130,
views: data,
layout: 'horizontal'
});
win.add(scroll_view);