I have a simple iOS native app that loads a single UIWebView. I would like the webView to show an error message if the app doesn\'t COMPLETELY finish loading the initial page in
Swift coders can do it as follow:
var timeOut: NSTimer!
func webViewDidStartLoad(webView: UIWebView) {
self.timeOut = Timer.scheduledTimer(timeInterval: 7.0, target: self, selector: Selector(("cancelWeb")), userInfo: nil, repeats: false)
}
func webViewDidFinishLoad(webView: UIWebView) {
self.timeOut.invalidate()
}
func webView(webView: UIWebView, didFailLoadWithError error: NSError?) {
self.timeOut.invalidate()
}
func cancelWeb() {
print("cancelWeb")
}