2013-01-16 24 views
0

我不斷收到這個錯誤我使用情節串連圖板,並希望當我改變場景我不能似乎組native.showebpopup電暈盧阿

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' 

的webscreen取出時該代碼

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:[email protected]?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("[email protected]", 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 

回答

0

使用cancelwebpoup修復了代碼。這消除屏幕上的所有webpopups的原因布爾和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 
1

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

注:本地Web彈出對象,如其他本地對象不能在組中工作,並且始終顯示在常規顯示對象(矢量,圖像和文本)的頂部。

+0

如何在改變場景時去除它們? – clause

+0

本地popup = native.showWebPopup(「localpage1.html」,選項) - 結束時與其他顯示對象相同。彈出:removeSelf() – Arnold

+0

似乎沒有工作,即使當我將它設置爲全局它讀取它爲零時,在功能場景︰exitScene(event) – clause