UIWebView - 如何识别“最后一个"webViewDidFinishLoad 消息? [英] UIWebView - How to identify the "last" webViewDidFinishLoad message?

查看:16
本文介绍了UIWebView - 如何识别“最后一个"webViewDidFinishLoad 消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

webViewDidFinishLoad 消息似乎是在每次页面中的 any 对象被加载时发送的.有没有办法确定所有内容的加载都已完成?

The webViewDidFinishLoad message seems to be sent each time any object in the page has been loaded. Is there a way to determine that all loading of content is done?

推荐答案

有趣,我没想到它会这样工作.虽然我确定还有其他方法可以做到这一点(有没有办法从 webViewDidFinishLoad 消息中提取 URL,以便您可以看到哪个是完成加载的主页?),但我能想到的主要是使用估计进度来检查页面的进度,并在 100% 完成加载时触发你想做的任何事情,这就是我在我的应用程序中所做的.谷歌iphone webviewestimatedprogress"并点击第一个链接查看我写的关于如何做到这一点的指南.

Interesting, I wouldn't have thought it would work like that. Although I'm sure there are other ways to do it (is there a way to extract the URL from the webViewDidFinishLoad message so that you can see which one is the main page finishing loading?), the main thing I can think of is using the estimatedProgress to check the progress of the page and fire off whatever you want to do when it's 100% finished loading, which is what I do in my app. Google "iphone webview estimatedprogress" and click the first link for a guide I wrote on how to do this.

更新:

请在下面使用 phopkins 的答案而不是我的答案!在您的应用程序中使用私有 API 是个坏主意,您可能会被拒绝,而他的解决方案是正确的.

Please use phopkins' answer below instead of mine! Using private APIs in your apps is a bad idea and you will probably get rejected, and his solution is the right one.

这篇关于UIWebView - 如何识别“最后一个"webViewDidFinishLoad 消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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