UIWebView: when did a page really finish loading?

后端 未结 11 1226
轮回少年
轮回少年 2020-11-29 00:09

I need to know, when a web page has completely been loaded by UIWebView. I mean, really completely, when all redirects are done and dynamically loaded content is ready. I tr

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-29 00:18

    Since all these answers are old and webViewDidFinishLoad has been depreciated and many headaches later let me explain how to exactly know when a page has finished loading in a webkit (webview) with swift 4.2

    class ViewController: UIViewController, WKNavigationDelegate {
    
        @IBOutlet weak var activityIndicator: UIActivityIndicatorView!
    
        override func viewDidLoad() {
    
            webView.navigationDelegate = self
    
        }
    
        func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
    
        // it is done loading, do something!
    
        }
    
    }
    

    Of course I am missing some of the other default code so you are adding to your existing functions.

提交回复
热议问题