UIWebView - 如何识别“最后” webViewDidFinishLoad消息? [英] UIWebView - How to identify the "last" webViewDidFinishLoad message?
问题描述
每次加载页面中的任何对象时,似乎都会发送webViewDidFinishLoad消息。有没有办法确定所有内容加载都已完成?
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,以便您可以看到哪一个是主页完成加载?),我能想到的主要是使用estimatedProgress检查页面的进度,并在100%完成加载时触发你要做的任何事情,这就是我在我的应用程序中所做的。谷歌iphone webview estimatedprogress,点击我写的关于如何做的指南的第一个链接。
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屋!