0

5.1.2 では、反復によって生成されたボタンが機能しません。私のコードをコピーして、5.1.1 と 5.1.2 の iPad シミュレーターで試してみてください。違いがわかります。5.1.2 では、より良いケースでは、最初と 2 番目のボタンを起動します。

var win = Ti.UI.createWindow();

var data = [];

for(var i=1; i<=6; i++){

    var view = Ti.UI.createView({
        width : 320,
        top : 10,
        bottom : 0
    });



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


    data.push(view);

}

var scroll_view = Ti.UI.createScrollableView({
    showPagingControl : true,
    top : 130,
    views: data,
    layout: 'horizontal'
});



win.add(scroll_view);
4

1 に答える 1

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);
于 2016-01-30T15:58:15.503 に答える