webViewDidFinishLoad:过早开火? [英] webViewDidFinishLoad: Firing too soon?
问题描述
我正在尝试通过在加载页面时隐藏webView来加载不同的网页。但是,我看到一些图像密集型网站导致webViewDidFinishLoading过快启动,当我在那时显示webView然后一瞬间你得到上一页的视图。关于如何解决这个问题的任何想法?
I'm trying to transition between loading of different web pages by hiding the webView while it is loading a page. However, I'm seeing that some image intensive websites are causing webViewDidFinishLoading to fire too soon and when I show the webView at that point then for a split second you get a view of the previous page. Any ideas on how to resolve this?
推荐答案
如果页面上有Javascript,您可能需要等待它完成。最简单的方法似乎是将一些javascript发送到要执行的页面:
If there's Javascript on the page, you may need to wait for it to finish. The easiest way seems to be to send some javascript to the page to be executed:
-(void) webViewDidFinishLoad:(UIWebView *)webView
{
NSString *javaScript = @"<script type=\"text/javascript\">function myFunction(){return 1+1;}</script>";
[webView stringByEvaluatingJavaScriptFromString:javaScript];
// done here
}
话虽如此,我似乎仍然看到在webViewDidFinishLoad中webview没有完全更新的情况。
Having said that, I seem to still see cases where the webview isn't quite updated within webViewDidFinishLoad.
这篇关于webViewDidFinishLoad:过早开火?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!