webviews continue to show after tab bar is pressed

Having an issue with Storyboard and web views/tabbars. I can navigate from tab to tab and the view loads but then after leaving the view and coming back to a webview based tab bar it merges them and show both web views at the same time.

videos.lua screen

  
-- Called immediately after scene has moved onscreen:  
function scene:enterScene( event )  
 local vidgroup = self.view   
 media.playEventSound( "Tock.caf" )  
  
 function ListenforOrigin(event)  
 if event.isReachableViaWiFi == true then   
 webView = native.newWebView( 0, 22, 320, 380 )  
 webView:request( "http://www.origintech.net/index.php")  
 webView.hasBackground = false  
 vidgroup:insert(webView)  
 else   
 network.setStatusListener( "www.origintech.net", nil)  
 print("listener gone")  
 local alert = native.showAlert("Videos Require WiFi Access", "Connect to WiFi and try again", {"OK"}, onComplete)  
 end  
  
 end  
  
 if network.canDetectNetworkStatusChanges then  
 network.setStatusListener( "www.origintech.net", ListenforOrigin )  
  
 else  
 print("network reachability not supported on this platform")  
 end  
 return true  
 -----------------------------------------------------------------------------  
  
 -- INSERT code here (e.g. start timers, load audio, start listeners, etc.)  
  
 -----------------------------------------------------------------------------  
  
end  
-- Called when scene is about to move offscreen:  
function scene:exitScene( event )  
 local vidgroup = self.view  
  
-- vidgroup:removeSelf()  
 logo.isVisible = true  
  
 -----------------------------------------------------------------------------  
  
 -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)  
  
 -----------------------------------------------------------------------------  
  
end  
-- Called prior to the removal of scene's "view" (display group)  
function scene:destroyScene( event )  
 local vidgroup = self.view  
 webView:removeSelf()  
 webView = nil  
 vidgroup:removeSelf()  
 -----------------------------------------------------------------------------  
  
 -- INSERT code here (e.g. remove listeners, widgets, save state, etc.)  
  
 -----------------------------------------------------------------------------  
  
end  

twitter.lua screen

local storyboard = require( "storyboard" )  
local scene = storyboard.newScene()  
local twitterwebView  
logo.isVisible = false  
  
function scene:createScene( event )  
 local group = self.view  
 print("createscene")  
  
  
end  
-- Called immediately after scene has moved onscreen:  
function scene:enterScene( event )  
 local group = self.view  
 print("enterscene")  
 media.playEventSound( "Tock.caf" )  
 function MyNetworkReachabilityListener(event)   
 if event.isReachable == true then   
 twitterwebView = native.newWebView( 0, 22, 320, 380 )  
 twitterwebView:request( "twitter.html", system.ResourceDirectory )  
 twitterwebView.hasBackground = false   
 group:insert(twitterwebView)  
 else   
 network.setStatusListener( "twitter.com", nil)  
 local alert = native.showAlert("Twitter Requires Internet Connection", "Connect to Internet and try again", {"OK"}, onComplete)   
 end   
 end  
 if network.canDetectNetworkStatusChanges then  
 network.setStatusListener( "twitter.com", MyNetworkReachabilityListener )   
 else  
 print("network reachability not supported on this platform")  
 end  
 return true  
  
  
end  
-- Called when scene is about to move offscreen:  
function scene:exitScene( event )  
 local group = self.view  
 logo.isVisible = true  
  
 print("exitScene")  
 -----------------------------------------------------------------------------  
  
 -- INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)  
  
 -----------------------------------------------------------------------------  
  
end  
-- Called prior to the removal of scene's "view" (display group)  
function scene:destroyScene( event )  
 local group = self.view  
 twitterwebView:removeSelf()  
 twitterwebView = nil  
 print("destroyscene")  
  
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  

main.lua screen

[code]


– main.lua


local widget = require(“widget”)

local storyboard = require “storyboard”
local _H = display.contentHeight;
local _W = display.contentWidth;

display.setStatusBar( display.HiddenStatusBar )
– load scenetemplate.lua
storyboard.gotoScene( “scenetemplate” )

– Add any objects that should appear on all scenes below (e.g. tab bar, hud, etc.):

local sbHeight = 0
local tbHeight = 44
local top = sbHeight + tbHeight

– create a gradient for the top-half of the toolbar
–local toolbarGradient = graphics.newGradient( {168, 181, 198, 255 }, {139, 157, 180, 255}, “down” )
local toolbarGradient = graphics.newGradient({178,34,34,255},{178,100,100,255},“down”)
– create toolbar to go at the top of the screen
local titleBar = widget.newTabBar{
top = sbHeight,
gradient = toolbarGradient,
bottomFill = { 178, 34, 34, 255 },
height = 44
}

– create embossed text to go on toolbar
local titleText = display.newEmbossedText( “California Bar Exam”, 0, 0, native.systemFontBold, 20 )
titleText:setReferencePoint( display.CenterReferencePoint )
titleText:setTextColor( 255 )
titleText.x = 160
titleText.y = titleBar.y

– create a shadow underneath the titlebar (for a nice touch)
local shadow = display.newImage( “shadow.png” )
shadow:setReferencePoint( display.TopLeftReferencePoint )
shadow.x, shadow.y = 0, top
shadow.xScale = 320 / shadow.contentWidth
shadow.alpha = 0.45

– background image
background = display.newImage(“nk_background.png”)
background:toBack()

logo = display.newImage(“logo.png”)
logo.x = _W/2; logo.y = _H/2 - 50

local tabButtons = {
{
label=“Home”,
default=“home.png”,
width=24, height=24,
onPress=function() storyboard.gotoScene( “scenetemplate” ); end,
selected=true
},
{
label=“Books”,
default=“books.png”,
width=34, height=24,
onPress=function() storyboard.gotoScene(“books”);end,
},
{
label=“Videos”,
default=“movie.png”,
width=28, height=24,
onPress=function() storyboard.gotoScene(“videos”);end,
},
{
label=“Twitter”,
default=“talk_bubble.png”,
width=30,height=24,
onPress=function() storyboard.gotoScene(“twitter”);end,
},
{
label=“Contact Us”,
default=“emailnew.png”,
width=42,height=24,
onPress=function() storyboard.gotoScene(“contact”);end,
}
}
local navTabs = widget.newTabBar{
top=display.contentHeight-50,
buttons=tabButtons
}

[/code] [import]uid: 18783 topic_id: 28954 reply_id: 328954[/import]

Maybe removing the webview on the exitScene event could help? [import]uid: 113596 topic_id: 28954 reply_id: 116604[/import]

I unfortunately have tried it both ways… I am beginning to think that native webview just don’t play nice with the scene purging. [import]uid: 18783 topic_id: 28954 reply_id: 116700[/import]

Btw why do you have the webview in the enterScene? The way I understood storyboard, if you don’t remove objects/listeners created in eventScene on exitScene, the app will create these objects/listeners on every enterScene which causes multiple instances of them.
Regards [import]uid: 113596 topic_id: 28954 reply_id: 116775[/import]