使用的版本是 1.5.1 beta 2,
我將ScrollView包裝成一個Prefab,
結構如下…

然後定義了一個script放在 prefab@ScrollView 節點上面,
裡面有這樣的定義:
cc.Class(
{
extends: cc.Component,
properties: {},
onLoad: function ()
{
this.ScrollView = this.node.getComponent( cc.ScrollView );
this.ContentNode = this.node.getChildByName( '@view' ).getChildByName( '@content' );
this.nodes =
{
View: this.node.getChildByName( '@view' ),
BarV: this.node.getChildByName( '@barVBG' ),
BarH: this.node.getChildByName( '@barHBG' ),
};
}
});
接著,以下的代碼說明問題…
//假設目前的prefab已放置到 Canvas上 ( Path: Canvas/ScrollView )
var scrollView = cc.find( 'Canvas/ScrollView' ).getComponent( 'MyScript' );
//我載入一個prefab後,用cc.instantiate創建出來後 (載入的代碼略過)
var newNode = cc.instantiate( prefabRes );
//接著取得content節點的方式, 將會影響問題是否發生
var content = scrollView.ContentNode; //這樣會有問題 ( newNode裡的圖片都會不見 )
var content = cc.find( 'Canvas/ScrollView/@view/@content' ); //這樣則是沒問題的
content.addChild( newNode );
請問這個是現在有什麼限制嗎?