webViewDidFinishLoad: Firing too soon?

前端 未结 2 396
无人共我
无人共我 2021-01-02 01:17

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 a

相关标签:
2条回答
  • 2021-01-02 01:24

    I've encountered this problem as well. Although I haven't found a solution, I've worked around the problem by introducing a 0.5 second delay before showing the UIWebView once the webViewDidFinishLoading delegate method is called.

    - (void)webViewDidFinishLoad:(UIWebView *)webView
    {
        [self performSelector:@selector(displayWebView) withObject:nil afterDelay:0.5];
    }
    
    0 讨论(0)
  • 2021-01-02 01:35

    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
    }
    

    Having said that, I seem to still see cases where the webview isn't quite updated within webViewDidFinishLoad.

    0 讨论(0)
提交回复
热议问题