UIWebViewOfNetworkStatus display is described in this article.UIWebViewTo displayWebpageIt is very simple. You only needUIWebViewSend an NSURLRequest. But you will find that it is not user-friendly, because you do not know the current situation,WebpageWhether the file is being loaded or not. Mobile safari is very user-friendly, not only has blue progressbar, but also has a network activity indicator in the status bar.
We also need to add this feature to the application. Adding a network activity indicator is actually very simple. The Code is as follows:
- - (void)showLoading
- {
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
- self.theActivityView.hidden = NO;
- [self.theActivityView startAnimating];
- }
- - (void)hideLoading
- {
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
- self.theActivityView.hidden = YES;
- [self.theActivityView stopAnimating];
- }
- - (void)webViewDidStartLoad:(UIWebView *)webView
- {
- [self showLoading];
- NSLog(@"start load");
- }
- - (void)webViewDidFinishLoad:(UIWebView *)webView
- {
- [self hideLoading];
- NSLog(@"finish load");
- }
- - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
- {
- [self hideLoading];
- NSLog(@"error load");
- }
- - (void)showLoading
- {
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
- self.theActivityView.hidden = NO;
- [self.theActivityView startAnimating];
- }
- - (void)hideLoading
- {
- [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
- self.theActivityView.hidden = YES;
- [self.theActivityView stopAnimating];
- }
- - (void)webViewDidStartLoad:(UIWebView *)webView
- {
- [self showLoading];
- NSLog(@"start load");
- }
- - (void)webViewDidFinishLoad:(UIWebView *)webView
- {
- [self hideLoading];
- NSLog(@"finish load");
- }
- - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
- {
- [self hideLoading];
- NSLog(@"error load");
- }
TheActivityView is an instance of UIActivityIndicatorView. In this way, when the UIWebView is loadedWebpageThere will be an indicator in the status bar and a UIActivityIndicatorView in the UIWebView frame to showWebpageLoading.
After studying how to implement progressbar, no method is found yet. Because there are only a few delegate methods available for UIWebView, it does not help to display the progress bar. You can only find another method.
Summary: DetailsUIWebViewOfNetworkThe content of the Status display is complete. I hope this article will help you.