how does one check if UIWebView is empty or not

前端 未结 4 759
醉话见心
醉话见心 2021-02-15 17:02

I need to check if a webview when completed loading has any content or not.

What I require is simple. Its a small webview strip at the bottom of my pages (like an advert

4条回答
  •  野性不改
    2021-02-15 17:58

    Just replying to an old post, but maybe new arrivals will find it useful. I struggled with the same problem and found this solution to work in my case:

    if (webView.request.URL.absoluteURL == nil) {
            NSLog(@"nil webby");
            NSLog(@"url: %@", webView.request.URL.absoluteURL);
            // Perform some task when the url is nil
        } else {
            NSLog(@"loaded webby");
            NSLog(@"url: %@", webView.request.URL.absoluteURL);
            // Perform some task when the url is loaded
    }
    

    You can call it from the webViewDidFinishLoad: method.

提交回复
热议问题