如何检测UIWebView何时完全加载? [英] How to detect when a UIWebView has completely finished loading?

查看:150
本文介绍了如何检测UIWebView何时完全加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为UIWebView构建一个过滤器,我正在努力检测UIWebView何时完全加载。我使用了以下两种方法

I am trying to build a filter for a UIWebView and I am struggiling to detect when the UIWebView has completely finished loading. I have used the following two methods

– webView:shouldStartLoadWithRequest:navigationType:
– webViewDidFinishLoad:

但问题是当页面包含要加载的帧和其他内容时,这些将被多次调用。

but the issue is that these will be called multiple times when a page has frames and additional content to load.

我需要知道什么时候视图已经完全加载并且没有更多要提取的内容。然后,当内容加载后,我可以根据已批准的URL列表检查页面的URL。

What I need is to know when the view has completely loaded and there is no more content to fetch. Then when the content has loaded I can check to URL of the page against a list of approved URLS.

任何想法?

推荐答案

使用 UIWebViewDelegate 协议方法 webViewDidFinishLoad webView的isLoading属性

 - (void)webViewDidFinishLoad:(UIWebView *)webView
 {
    //Check here if still webview is loding the content
    if (webView.isLoading)
       return;

    //after code when webview finishes
    NSLog(@"Webview loding finished");
 }

这篇关于如何检测UIWebView何时完全加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆