0

I'm trying to understand how can I make one Webview from a URL to know when it starts loading and when it finishes. With the following code

class WebsiteViewController: UIViewController, UIWebViewDelegate {
   override func viewDidLoad() {
        super.viewDidLoad()
       loadWebPage()
  }
func loadWebPage(){
        let theURL = "https://www.example.com/"
        let theRequestURL = NSURL (string: theURL)
        let theRequest = NSURLRequest (URL: theRequestURL!)
        webView.delegate = self
        webView.loadRequest(theRequest)
    }
    func webViewDidStartLoad(webView : UIWebView) {
        //UIApplication.sharedApplication().networkActivityIndicatorVisible = true
        print("Started")
    }

    func webViewDidFinishLoad(webView : UIWebView) {
        //UIApplication.sharedApplication().networkActivityIndicatorVisible = false
        print("Finished")
    }

}

I've got these printed results

Started
Started
Finished
Finished
Started
Finished
Started
Finished
Finished

Any idea why??

Konstantinos Natsios
  • 2,874
  • 9
  • 39
  • 74

0 Answers0