How to detect when a UIWebView has completely finished loading?(如何检测 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 何时完全完成加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何检测 UIWebView 何时完全完成加载?


基础教程推荐
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01