CocosCreator 2.0.5 scrollView布局问题

scrollView动态添加 Item时,第一个添加的Item却排到最后了,其他的Item又是正常的。设置的Layout以及UI效果如下图 参考Demo

你好 你可以把for循环实例化预制件的逻辑放在loadRes中,这样就能避开异步调用带来的问题,达到你的需求。

this._scrollViewContent = this.scrollView.content;
        cc.loader.loadRes("test", cc.Prefab, function (err, prefab) {
            for (var i = 0; i < 3; i++) {
                var a = cc.instantiate(prefab);
                a.children[0].getComponent(cc.Label).string = 'index'+i;
                this._scrollViewContent.addChild(a);
             }
        }.bind(this));