Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
594 views
in Technique[技术] by (71.8m points)

ios - Show progress bar until it load the data in UIWebView IOS7

Hi in my application i have UIWebView which loads the pdf file using URL its very large file its taking too much time to load. Now i want show the user that like its loading progress until it get load the my pdf once my file loaded its has hide the progress bar, how can I achieve this?

My webview code.

- (void)viewDidLoad
{
   [super viewDidLoad];

   NSString *pdf =@"http://jesusredeems.com/mag/pdf/JRE-2014-03.pdf";

   NSURL *url = [NSURL URLWithString:pdf];

   NSURLRequest *myRequest = [NSURLRequest requestWithURL:url];
   [webview loadRequest:myRequest];

}

I'm using the above code to load my pdf, how I can use the progress bar for file loading?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should start/stop the progressbar in webview delegate methods.

Add following line in your viewDidLoad.

webview.delegate = self;

Add following functions in your controller...

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    //Start the progressbar.. 
    return YES;
}

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
    //Stop or remove progressbar
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    //Stop or remove progressbar and show error
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...