我似乎无法将native.showpopup corona lua分组

时间:2013-01-16 14:53:00

标签: lua native corona

我一直收到这个错误,我正在使用故事板,并希望在我更改场景时删除网页

contact.lua:99: ERROR: table expected. If this is a function call, you might have used '.' instead of ':'
stack traceback:
    [C]: ?
    [C]: in function 'insert'

何时使用此代码

local myMap = native.showWebPopup(450, 260, 460, 340 , "http://google.com", options )
print("done")
group:insert(myMap)

无论如何我可以分组吗? 编辑:这是我正在使用弹出窗口的页面,我希望能够在我更改页面时删除弹出窗口

local storyboard = require( "storyboard" )
local scene = storyboard.newScene()

-----------------------------------------------------------------------------------------
-- BEGINNING OF YOUR IMPLEMENTATION
-- 
-- NOTE: Code outside of listener functions (below) will only be executed once,
--       unless storyboard.removeScene() is called.
-- 
-----------------------------------------------------------------------------------------

-- Called when the scene's view does not exist:
function scene:createScene( event )

    local group = self.view 


display.setStatusBar( display.HiddenStatusBar )

    local function web(event)
        if event.phase == 'ended' then
        system.openURL( "http://www.whitehart.co.uk/app.php" )
        end
        return true
    end
    local function email(event)
        if event.phase == 'ended' then
        system.openURL( "mailto:multimedia@whitehart.co.uk?subject=Contact%20From%20App" )
        end
        return true
    end
    local function tel(event)
        if event.phase == 'ended' then
        system.openURL( "tel:01291 650761" )
        end
        return true
    end

local background = display.newImageRect( "back/bg_contact.jpg", 1024, 768 )
background.x = 512
background.y = 384
background.alpha = 0.8
group:insert(background)

local subtxt = display.newText("Get In Touch", 50, 270, 400, 0, native.systemFontBold, 24)
subtxt:setTextColor(255, 255, 255)
group:insert(subtxt)
local subtxt = display.newText("+44(0) 1291 650761", 150, 330, 400, 0, native.systemFontBold, 16)
subtxt:setTextColor(255, 255, 255)
group:insert(subtxt)
local subtxt = display.newText("multimedia@whitehart.co.uk", 150, 420, 400, 0, native.systemFontBold, 16)
subtxt:setTextColor(255, 255, 255)
group:insert(subtxt)
local subtxt = display.newText("www.whitehart.co.uk", 150, 500, 400, 0, native.systemFontBold, 16)
subtxt:setTextColor(255, 255, 255)
group:insert(subtxt)
local mapbg = display.newRect( 440, 250, 480, 360 )
mapbg.alpha = 0.2
group:insert(mapbg)


local btntel = display.newImageRect( "back/btn_tel_white.png", 50, 50 )
btntel.x = 100
btntel.y = 350

local btnemail = display.newImageRect( "back/btn_email_white.png", 50, 50 )
btnemail.x = 100
btnemail.y = 430

local btnweb = display.newImageRect( "back/btn_web_white.png", 50, 50 )
btnweb.x = 100
btnweb.y = 510

popup = native.showWebPopup(450, 260, 460, 340 , "http://google.com", options )


btnweb:addEventListener('touch', web)
btnemail:addEventListener('touch', email)
btntel:addEventListener('touch', tel)


group:insert(btnweb)
group:insert(btnemail)
group:insert(btntel)



    -- all objects must be added to group (e.g. self.view)
end








-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
    local group = self.view

    -- do nothing

end

-- Called when scene is about to move offscreen:
function scene:exitScene( event )
    local group = self.view
  popup:removeSelf()
  end

-- If scene's view is removed, scene:destroyScene() will be called just prior to:
function scene:destroyScene( event )
    local group = self.view

    -- INSERT code here (e.g. remove listeners, remove widgets, save state variables, etc.)

end

-----------------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
-----------------------------------------------------------------------------------------

-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener( "createScene", scene )

-- "enterScene" event is dispatched whenever scene transition has finished
scene:addEventListener( "enterScene", scene )

-- "exitScene" event is dispatched whenever before next scene's transition begins
scene:addEventListener( "exitScene", scene )

-- "destroyScene" event is dispatched before view is unloaded, which can be
-- automatically unloaded in low memory situations, or explicitly via a call to
-- storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( "destroyScene", scene )

-----------------------------------------------------------------------------------------

return scene

2 个答案:

答案 0 :(得分:1)

http://developer.coronalabs.com/reference/index/nativeshowwebpopup

注意:Native Web Popup对象与其他本机对象一样,不能在组中工作,并且始终显示在常规显示对象(矢量,图像和文本)之上。

答案 1 :(得分:0)

使用cancelwebpoup修复代码。这将删除屏幕上的所有webpopup bool的原因和if语句出于某种原因故事板在输入后存在一个场景,删除了网络弹出窗口,无论如何这是现在的解决方法,直到可以做出更好的事情

    function scene:enterScene( event )
    local group = self.view
     native.showWebPopup(450, 260, 460, 340 , "http://google.com", options )
    poup=false
    -- do nothing

end

-- Called when scene is about to move offscreen:
function scene:exitScene( event )
    local group = self.view
    if popup==true then
     native.cancelWebPopup()
     popup=false
     else 
     popup=true
     end

    -- INSERT code here (e.g. stop timers, remove listenets, unload sounds, etc.)

end