iOS判斷UIWebView加載完成的方法

 UIWebview不一樣於WkWebview沒有加載進度屬性來判斷加載是否完成了html

它有個回調方法java

 

- (void)webViewDidFinishLoad:(UIWebView *)webView;web

這個方法的蘋果官方文檔關於它的說明也是含糊的ajax

 

- (void)webViewDidFinishLoad:(UIWebView *)webViewapp

Description測試

Sent after a web view finishes loading a frame.lua

Parametersspa

webViewxml

The web view has finished loading.htm

Availability

iOS (2.0 and later)

Declared In

UIWebView.h

Reference

UIWebViewDelegate Protocol Reference

經過測試,發現finishLoad方法走了,並不是加載完了。

 

結合js方法或許是更加完美的,參考這兩篇文章

http://www.w3school.com.cn/ajax/ajax_xmlhttprequest_onreadystatechange.asp

http://www.java2s.com/Book/JavaScript/DOM/document_readyState.htm

 

 NSString *readyState = [webView stringByEvaluatingJavaScriptFromString:@"document.readyState"];
      BOOL complete = [readyState isEqualToString:@"complete"];
    if (complete) {
        [self completeProgress];
    }
相關文章
相關標籤/搜索