Hello,
I have an app with a few scenes. One of them loads the webView with a web page which works fine. I then click to go to another scene. When I come back to the scene with the webView it is not there. I am adding the webView in the createScene event. But I am also adding the imgHeader and it is showing the second time when I return to the page. So am I supposed to purge this scene somewhere? Or what do you think I need to do to see the webView every time?
Thanks for your help!!
Warren
---------------------------------------------------------------------------------- -- -- SceneFacebookWeb.lua -- ---------------------------------------------------------------------------------- local storyboard = require( "storyboard" ) storyboard.removeAll() local scene = storyboard.newScene() local widget = require ( "widget" ) local imgHeader local webView -- Touch event listener for background image --local function onSceneTouch( self, event ) local function onSceneTouch( event ) if event.phase == "began" then --MENU BAR if event.x \> 0 and event.y \> 90 and event.x \< 48 and event.y \< 121 then webView:removeSelf() storyboard.gotoScene( "SceneHome" ) end if event.x \> 47 and event.y \> 90 and event.x \< 100 and event.y \< 121 then webView:removeSelf() storyboard.gotoScene( "SceneEvents" ) end if event.x \> 99 and event.y \> 90 and event.x \< 182 and event.y \< 121 then webView:removeSelf() storyboard.gotoScene( "SceneHappyHour" ) end if event.x \> 181 and event.y \> 90 and event.x \< 251 and event.y \< 121 then webView:removeSelf() storyboard.gotoScene( "SceneFacebook" ) end if event.x \> 250 and event.y \> 90 and event.x \< 320 and event.y \< 121 then webView:removeSelf() storyboard.gotoScene( "SceneLocation" ) end end return true end --------------------------------------------------------------------------------- -- BEGINNING OF YOUR IMPLEMENTATION --------------------------------------------------------------------------------- -- Called when the scene's view does not exist: function scene:createScene( event ) local screenGroup = self.view imgHeader = display.newImage( "Header.jpg") screenGroup:insert( imgHeader ) imgHeader:addEventListener("touch", onSceneTouch) display.setDefault( "background", 0, 0, 0 ) webView = native.newWebView( 0, 123, 320, 357 ) webView:request( "http://www.facebook.com" ) group:insert( webView ) screenGroup:insert( imgHeader ) end -- Called immediately after scene has moved onscreen: function scene:enterScene( event ) --storyboard.purgeScene( "sceneFacebook" ) imgHeader.ready = true --[[-- Update Lua memory text display local showMem = function() imgHeader:addEventListener( "touch", imgHeader ) end local memTimer = timer.performWithDelay( 1000, showMem, 1 ) --]] end -- Called when scene is about to move offscreen: function scene:exitScene( event ) local group = self.view imgHeader.ready = false end -- Called prior to the removal of scene's "view" (display group) function scene:destroyScene( event ) local group = self.view 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 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