storyboard scene exitScene not being called

Hello.  I’m using a tabbar for navigating scenes in a storyboard.  in a scene, I have a webview.  When I change scenes the webview stays up.  The scene group is removed and all that was inserted into it, but I can’t get rid of the webview.  I have this code in that scene:

function scene:createScene( event )     local group = self.view        local screen\_adjustment = 1   local background = display.newImage("assets/top.jpg", true)   background.anchorX, background.anchorY = 0, 0   background.xScale = (screen\_adjustment  \* background.contentWidth)/background.contentWidth   background.yScale = background.xScale   background.x = 0   background.y = 0     group:insert( background )        local webView = native.newWebView( 0, 0, display.contentWidth, display.contentHeight - 350 )   webView:request( "assets/2.html", system.ResourceDirectory )   webView.anchorX, webView.anchorY = 0, 0   webView.x = 0   webView.y = 130   group:insert( webView ) end function scene:exitScene(event)   print( "exitScene called." )   local group = self.view   native.cancelWebPopup()   storyboad.remove (webView)   display.remove (webView)   group.remove ( webView )   if webView then     webView.parent:remove(webView)     webView = nil   end   webView:removeSelf()   webView = nil end  

but I notice the print statement is never called.  The exitScene isn’t being called?  

In my main.lua where the tabbar is created I tried this too:

local tabButtons =  {   {         width = 175, height = 155,         defaultFile = "assets/1\_practices.png",         overFile = "assets/1\_practices\_on.png",         onPress = function()        storyboard.removeAll()       storyboard.gotoScene( "screen1" ); end,         selected = false     },  ...

but that didn’t kill it either.

Any ideas?  I’m running out of guesses.

I track whether I have a webView open in a global variable. My webViews have a back button which call a close function. If user hits a different tabBar button then my tabBar function calls the following function (in main.lua) to clean any possible webPopups that might be open at that time before moving to the other scene.

local function closeWebPopup() if myGlobals.isWebPopup then native.cancelWebPopup() myGlobals.isWebPopup = false end end

I also create one gotoSceneBlabla() for each of my scenes in my main.lua and put all my scene change code in there and then call these functions from the relevant tabBar button. That might work better than putting the function in the tabBar button definition itself.

Hope this helps. Best of luck.

Thanks for the reply!  I switched to using WebPopUp and your closeWebPopup() functions works well.  But, it works too well.  Now I can’t open the webPopUp again if that scene is loaded.  The scene and it’s image appear, but no webPopUp.

You’re most welcome. Move your webPopup creation in the scene’s enterScene(). createScene() only gets called once when the scene is first opened unless you purge/remove that scene at some point which should not be necessary. Move to enterScene and you should be ok. 

YAY!  That works.  Now I’m on to break something else! :wink:

Bring it on!!!  :slight_smile:

Just an update, my exitScene wasn’t being called because I didn’t have a listener for it. 

scene:addEventListener( "exitScene", scene )

Now I have a couple ways to make it work :slight_smile:

I track whether I have a webView open in a global variable. My webViews have a back button which call a close function. If user hits a different tabBar button then my tabBar function calls the following function (in main.lua) to clean any possible webPopups that might be open at that time before moving to the other scene.

local function closeWebPopup() if myGlobals.isWebPopup then native.cancelWebPopup() myGlobals.isWebPopup = false end end

I also create one gotoSceneBlabla() for each of my scenes in my main.lua and put all my scene change code in there and then call these functions from the relevant tabBar button. That might work better than putting the function in the tabBar button definition itself.

Hope this helps. Best of luck.

Thanks for the reply!  I switched to using WebPopUp and your closeWebPopup() functions works well.  But, it works too well.  Now I can’t open the webPopUp again if that scene is loaded.  The scene and it’s image appear, but no webPopUp.

You’re most welcome. Move your webPopup creation in the scene’s enterScene(). createScene() only gets called once when the scene is first opened unless you purge/remove that scene at some point which should not be necessary. Move to enterScene and you should be ok. 

YAY!  That works.  Now I’m on to break something else! :wink:

Bring it on!!!  :slight_smile:

Just an update, my exitScene wasn’t being called because I didn’t have a listener for it. 

scene:addEventListener( "exitScene", scene )

Now I have a couple ways to make it work :slight_smile: