How can i know web view is loading completed

依然范特西╮ 提交于 2019-12-10 10:48:20

问题


i have web view in that i am loading pdf file .

pdf file has 2 mb size so it tacking time. i want to add indicator .

for that how can i know my file is loaded in web view ? ...


回答1:


James P has the right answer (^'ed), but here is the code to show and hide the indicator.

After you've registered with the UIWebViewDelegate...

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    // Other stuff...
}

And then

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    // Other stuff...
}

Also you probably want to check for failures and hide the activity indicator there as well...

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    // Other stuff...
}



回答2:


UIWebViewDelegate

in particular:

- (void)webViewDidFinishLoad:(UIWebView *)webView



回答3:


first Add the delegate "UIWebViewDelegate", then you can use the below methods.

– webView:shouldStartLoadWithRequest:navigationType: – webViewDidStartLoad: – webViewDidFinishLoad:
– webView:didFailLoadWithError:




回答4:


You could pull your PDF down using ASIHTTPRequest, which would let you set up a progress bar showing real progress, and then feed it to your UIWebView once it's downloaded.

EDIT: ASIHTTPRequest is a free third-party library that provides a MUCH improved interface to iOS HTTP client functions. LOTS of code samples and instructions here: http://allseeing-i.com/ASIHTTPRequest/How-to-use



来源:https://stackoverflow.com/questions/4658227/how-can-i-know-web-view-is-loading-completed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!