Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop Activity Indicator in Status Bar?

I'm near completing my application, but I'm running into an issue. Obviously, my web view needs an activity indicator for the app to be accepted. I have the following already:

- (void)viewDidLoad
{
   [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@""]]]; // I removed the website for privacy's sake

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}

Problem is that it won't stop spinning when I need it to (i.e. even after the page is loaded, it doesn't stop)

Any suggestions? Any help is appreciated!

like image 211
musician137 Avatar asked Oct 12 '11 19:10

musician137


3 Answers

Implement the UIWebViewDelegate in your class file that holds the UIWebView, and insert the following two methods:

- (void)webViewDidStartLoad:(UIWebView *)webView
- (void)webViewDidFinishLoad:(UIWebView *)webView

In the start method, place your:

[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

... and in the finish, place:

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

Hope this helps!

like image 115
Luke Avatar answered Sep 30 '22 16:09

Luke


In the web views delegate you can do:

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
like image 24
chown Avatar answered Sep 30 '22 14:09

chown


you need to call

[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;

to get it to stop

like image 41
cpjolicoeur Avatar answered Sep 30 '22 15:09

cpjolicoeur