I can't remove a native.newWebView() on IOS

I created a app for load remote html file in my view, but after loaded the html file I cant remove the “webview” below my code:

local topweb = display.screenOriginY + display.statusBarHeight + 50

function listenerLink(event)
        webView = native.newWebView(0 , 0, display.contentWidth, display.contentHeight - topweb)
        webView:request( “http://myurl.com/myfile.html”)  
        webView:setReferencePoint(display.TopLeftReferencePoint)
        webView.x = display.screenOriginX
        webView.y = topweb
        return true
    end
   
    linktoUrl= display.newText(“View link”, 0, 0, native.systemFont, 14)
    linktoUrl:setTextColor(0, 0,0)
    linktoUrl:addEventListener(“touch”, listenerLink)

function backBtnRelease( event )       
            webView:removeSelf()
            webView = nil         
end
– back button
local backBtn = ui.newButton{
        default = “images/back_button.png”,
        over = “images/back_button_over.png”,
        onRelease = backBtnRelease
  }

backBtn:setReferencePoint(display.TopLeftReferencePoint)
backBtn.x = display.screenOriginX

backBtn.y = display.screenOriginY

Hi @aln_fsp3,

The “ui.” button library is rather old, and I don’t recall its specific functionality, internally. Are you getting a positive response from the button? Can you confirm so by doing a “print()” statement in the “backBtnRelease()” function?

Thanks,

Brent Sorrentino

I checked it and ui library works, I can “print” values in the console when I touch the button

Hi @aln_fsp3,

Can you try locally scoping “webView” above the line “function listenerLink(event)” ?

[lua]

local webView

function listenerLink(event)

[/lua]

Thanks,

Brent

Hi @aln_fsp3,

The “ui.” button library is rather old, and I don’t recall its specific functionality, internally. Are you getting a positive response from the button? Can you confirm so by doing a “print()” statement in the “backBtnRelease()” function?

Thanks,

Brent Sorrentino

I checked it and ui library works, I can “print” values in the console when I touch the button

Hi @aln_fsp3,

Can you try locally scoping “webView” above the line “function listenerLink(event)” ?

[lua]

local webView

function listenerLink(event)

[/lua]

Thanks,

Brent

function scene:hide( event )
local sceneGroup = self.view
if event.phase == “will” then
if webView and webView.removeSelf then
webView:removeSelf()
webView = nil
end
end
end

https://github.com/coronalabs/business-app-sample/blob/master/webpage.lua

function scene:hide( event )
local sceneGroup = self.view
if event.phase == “will” then
if webView and webView.removeSelf then
webView:removeSelf()
webView = nil
end
end
end

https://github.com/coronalabs/business-app-sample/blob/master/webpage.lua