Button removal in Corona

纵然是瞬间 提交于 2020-01-05 08:14:54

问题


I'm trying to nest pages and such with button presses in an app I am working on. However, as a widget, it carries over and such and must be removed using display.remove() or :removeSelf. I'm trying to make these buttons delete/remove themselves from the view as they are pressed and the next page is loaded, but when I do this it either does not work, or throws a runtime error. Suggestions?

Edit: This is what I am currently using, although it leaves the button gone permanently after click. `

local onButtonEvent = function (event )
    if event.phase == "release" then
        display.remove( myButton )
        myButton = nil
        display.remove( buttonGroup )
        buttonGroup = nil
        storyboard.gotoScene( "shape" )
    end
end

回答1:


Here's another way. Why don't you set

myButton.isVisible = false

inside your onButtonEvent function.

And I've never used StoryBoard, but I'm pretty sure there is a event fired ("willEnterScene" I think) when you enter the scene.

So you can set mybutton.isVisible = true there




回答2:


this will work in lua/ Corona:

    MyButton:removeSelf( )

removes it completely.

Hope that helps !



来源:https://stackoverflow.com/questions/10883570/button-removal-in-corona

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!