电晕中的按钮移除 [英] Button removal in Corona
问题描述
我正在尝试在我正在开发的应用程序中嵌套页面等,并通过按下按钮来实现.但是,作为小部件,它会随身携带,因此必须使用display.remove()或:removeSelf将其删除.我试图使这些按钮在被按下并加载下一页时从视图中删除/删除它们自己,但是当我这样做时,它要么不起作用,要么抛出运行时错误.有建议吗?
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?
这是我当前正在使用的,尽管单击后它使按钮永久消失了. `
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
推荐答案
这是另一种方法.为什么不设置
Here's another way. Why don't you set
myButton.isVisible = false
在您的onButtonEvent函数中
.
inside your onButtonEvent function.
我从未使用过StoryBoard,但是我很确定当您进入场景时会触发一个事件(我认为是"willEnterScene").
And I've never used StoryBoard, but I'm pretty sure there is a event fired ("willEnterScene" I think) when you enter the scene.
因此您可以在那里设置mybutton.isVisible = true
So you can set mybutton.isVisible = true
there
这篇关于电晕中的按钮移除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!