I already tried to find here a similar question without success.
I have a UITableView with various kinds of contents and cells. In particular, it can show a custom UITableViewCell with a WKWebView. Sometimes this web view has an autoplay video that starts when I configure the cell on willDisplayCell. Because of this autoplay feature, when I scroll up/down, the cell does not call the delegate method didEndDisplayingCell and the video stays active in the background. The user needs to close the viewController or the whole App.
I tried to save on a list all the dequeued cells with web view and on scrollViewDidEndDecelerating manually set the content of the saved cell's web view to HTML "" using:
cell.webView?.loadHTMLString("", baseURL: nil)
In this way, the web view properly stops playing the video in the background but the problem is that even using this approach the cell is not enqueued and the didEndDisplayingCell: is not called, so when I scroll to that cell again, I can't redo correct configuration to reload the web view.
Do you have some tips or tricks?