hi all.. i want to start activityindicator whenever user press any link on a webview please help....
Take a look at UIWebViewDelegate Protocol.
It will allow your delegate to be notified whenever the webview is starting to load new content, which, presumably, is the case whenever a link has been pressed. The delegate method you want is webViewDidStartLoad: - in its implementation you could then easily set up or start your activity indicator.
If you wanna show network activity indicator just put
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
and then
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
when you wanna hide it
while if you needs UIActivityIndicator
you have to define it in your controller then Outlet it in XIB and then
show
[activityIndicator startAnimating];
hide
[activityIndicator stopAnimating];
First assign the ViewController which the UIWebView appears in as its delegate: Do this either by control-dragging from the UIWebView to the File's Owner object in InterfaceBuilder or in code:
[myWebView setDelegate:myViewController];
Then in your ViewController.m file you can now use the delegate methods to detect when pages are being loaded. These delegate methods will be triggered every time a link or new page is loaded in the UIWebView.
- (void)webViewDidStartLoad:(UIWebView *)webView {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
[[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
}