或者我可以在将项目添加到ScrollView
小部件后访问它吗?
例子:
local scrollView = widget.newScrollView {...}
scrollView:insert(display.newImage("img1.png", 0, 0))
scrollView:insert(display.newImage("img2.png", 100, 0))
接下来我想从以下位置删除第一张图片scrollView
:
scrollView:remove(1) -- has no effect
更新:我的解决方案:
local scrollView = widget.newScrollView {...}
scrollView.content = {}
scrollView.content[#scrollView.content+1]= display.newImage("img1.png", 0, 0)
scrollView:insert(scrollView.content[#scrollView.content])
scrollView.content[#scrollView.content+1]= display.newImage("img2.png", 0, 0)
scrollView:insert(scrollView.content[#scrollView.content])
...
-- at some point I want to delete some item
scrollView.content[n]:removeSelf()
table.remove(scrollView.content, n)