UIWebViewDelegate
methods/functions are not being called from custom web view`.
Code I've tried:
class CustomWebView: UIWebView, UIWebViewDelegate {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.delegate = self
}
// Web view delegate method - not called upon web view load
func webViewDidFinishLoad(_ webView: UIWebView) {
print("webViewDidFinishLoad")
}
/*
// tried this also
override func didMoveToSuperview() {
super.didMoveToSuperview()
self.delegate = self
}
*/
}
// View controller code
class WebControllerVC: UIViewController, UIWebViewDelegate {
@IBOutlet weak var wvWebView: CustomWebView!
override func viewDidLoad() {
super.viewDidLoad()
wvWebView.delegate = self
wvWebView.loadHTMLString(htmlString, baseURL: nil) // htmlString is string variable with data in HTML format
}
}
I tried to look around following SO Posts, but can't see solution for custom web view.