我使用scrollView.lua进行滚动,但要退出它,我需要放回按钮,但滚动视图没有按钮动作事件
local menuBtn
local onMenuBtn = function( event )
if event.phase == "release" then
print ("I am in onMenuBtn btn action" )
scrollView:removeSelf(); scrollView = nil
menuBtn:removeSelf(); menuBtn = nil
director:changeScene( "slide1" )
end
end
menuBtn = ui.newButton
{
defaultSrc = "menubtn.png",
defaultX = 100,
defaultY = 42,
overSrc = "menubtn.png",
overX = 100,
overY = 42,
onEvent = onMenuBtn,
id = "menuBtn",
text = "",
font = "Helvetica",
textColor = { 255, 255, 255, 255 },
size = 16,
emboss = false
}
menuBtn.x = 50
menuBtn.y = 30
scrollView:insert( menuBtn )
请任何人帮助我
谢谢你, 马丹莫汉
答案 0 :(得分:1)
试试这个:
local listener
function listener:tap( event )
onMenuBtn( event ) --or just put your code straight here
end
menuBtn:addEventListener( "tap", listener );
答案 1 :(得分:0)
您可以使用widget.scrollView()来实现此目的,因为它更容易,并且不需要包含任何其他文件。以下链接可能对您有所帮助。
http://developer.coronalabs.com/reference/index/widgetnewscrollview