Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After deiniting webView, video embedded in the webView is still playing - iOS

My ViewController has a WKWebView that embeds JavaScript with a video. When I pop the view controller, deinit is called. In deinit, I nullify everything that related to webView.

However, after popping the view controller, the audio from the video is still playing. What am I missing?

deinit
{
    webView.removeObserver(self, forKeyPath: "estimatedProgress")
    webView.navigationDelegate = nil
    webView.scrollView.delegate = nil
    webView.removeFromSuperview()
    webView = nil
}
like image 365
Luda Avatar asked Oct 22 '25 18:10

Luda


1 Answers

I am sure it is because of some cycled retains of the webView. Try by setting empty data to webview in 'deinit'. This may solve your problem, but you have to fix cycled retain of your webview.

webView.loadRequest(NSURLRequest(URL: NSURL(string: "about:blank")))
like image 140
Arun Ammannaya Avatar answered Oct 25 '25 09:10

Arun Ammannaya