cocos版本:3.8.2
在scrollview组件的content里面添加了几个item之后,getMaxScrollOffset获取的还是UI界面里面的值,不是添加了item之后的值:
render(cb: { (e: math.Vec2): void; (arg0: math.Vec2): void; }) { for (let i = 0; i < 10; i++) { let newNode: Node = null if (!this.lvContent.children[i]) { newNode = instantiate(this.lvContent.children[0]) newNode.parent = this.lvContent } else { newNode = this.lvContent.children[i] } newNode.name = `${i}` newNode.getChildByName('Label').getComponent(Label).string = `第${i + 1}关` } cb(this.lvScrollview.getMaxScrollOffset()) }
this.lvScrollview.getMaxScrollOffset()获取的还是UI界面里的值