I'm having trouble figuring out the correct layout to add the netowrk activity indicator to my UIWebviews.
The problem:
I have a tab-based app with only some tabs that UIWebViews. Each of these have their own ViewController Files.
My current setup:
I have this line of code in my app delegate.h file
I have this code in each ViewController.m file
I've tried just adding import appdelegate.h to each viewcontroller.m file but it still says that it wont work and gives me an error. i feel like i'm missing a really big concept here about the activity indicator and how it should be implemented. my codes a mess, i know. any help or examples are appreciated.
The problem:
I have a tab-based app with only some tabs that UIWebViews. Each of these have their own ViewController Files.
My current setup:
I have this line of code in my app delegate.h file
Code:
@property (nonatomic, getter=isNetworkActivityIndicatorVisible) BOOL networkActivityIndicatorVisible;
I have this code in each ViewController.m file
Code:
- (void)webViewDidStartLoad:(UIWebView *)webView
{
// starting the load, show the activity indicator in the status bar
[UIApplication sharedApplication].isNetworkActivityIndicatorVisible = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
// finished loading, hide the activity indicator in the status bar
[UIApplication sharedApplication].isNetworkActivityIndicatorVisible = NO;
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
// load error, hide the activity indicator in the status bar
[UIApplication sharedApplication].isNetworkActivityIndicatorVisible = NO;
// report the error inside the webview
NSString* errorString = [NSString stringWithFormat:
@"<html><center><font size=+5 color='red'>An error occurred:<br>%@</font></center></html>",
error.localizedDescription];
[blogPage loadHTMLString:errorString baseURL:nil];
}
I've tried just adding import appdelegate.h to each viewcontroller.m file but it still says that it wont work and gives me an error. i feel like i'm missing a really big concept here about the activity indicator and how it should be implemented. my codes a mess, i know. any help or examples are appreciated.