Closed tjljw2000 closed 2 days ago
可以先确认下pager:getchild
返回的是不是nil
重新测试了一下,返回的不是nil,元素可以被删掉,但是UI不会更新
<window title="App示例" w="450" h="400" content_margin="0,0,0,0" >
<hview>
<button title="Add Button" event:click="onAddBtnClick" />
<button title="Remove Button" event:click="onRemoveBtnClick" />
</hview>
<hview id="season_paginator" spacing="0" content_margin="0,0,0,0" view-depend:row="2">
<button id="to_be_remove" title="To Be Remove"/>
<!-- here -->
</hview>
</window>
app = {}
app.loaded = function(param)
local w = param["window"]
app.w = w
w:show()
end
app.onRemoveBtnClick = function(param)
local pager = kiko.ui.get("season_paginator")
local child = pager:getchild("to_be_remove")
if child then
pager:removechild("to_be_remove")
app.w:message("Removed")
else
app.w:message("It's nil")
end
end
app.onAddBtnClick = function (param)
local pager = kiko.ui.get("season_paginator")
pager:addchild([[
<button id="to_be_remove" title="To Be Remove"/>
]])
end
后两个是动态add的按钮
已修复,可自行编译最新master,或者到群里下载编译好的文件
代码如下