UIWebview不同于WkWebview没有加载进度属性来判断加载是否完成了
它有个回调方法
- (void)webViewDidFinishLoad:(UIWebView *)webView;
这个方法的苹果官方文档关于它的说明也是含糊的
- (void)webViewDidFinishLoad:(UIWebView *)webView |
|||
Description |
Sent after a web view finishes loading a frame. |
||
Parameters |
|
||
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]; }
时间: 2024-10-25 20:40:01