Add a progress dialog showing the loading page on the Web view in iOS

advertisements

I am new to iOS development.Is there any method to show a progress dialog on webview which show loading page while page is being loading and dismisses after the page loaded.

Please recommend some good tutorials

Thanks in advance

here is my code what i am doing but nothing shows

@interface ViewController ()
@property (strong, nonatomic) UIActivityIndicatorView*loadingIndicator;
@end

@implementation ViewController
@synthesize myWebview;

- (void)viewDidLoad {
self.myWebview.delegate = (id<UIWebViewDelegate>)[self class];
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityIndicator.center = self.myWebview.center;
[activityIndicator setHidden:YES];
self.loadingIndicator=activityIndicator;
[self.view addSubview:self.loadingIndicator];
NSURL *url=[NSURL URLWithString:@"http://getaservice.pk/joomla"];
self.myWebview.delegate = (id<UIWebViewDelegate>)[self class];
NSURLRequest *request=[NSURLRequest requestWithURL:url];
[myWebview loadRequest:request];
[super viewDidLoad];

}
// Do any additional setup after loading the view, typically from a nib.

     -(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request     navigationType:(UIWebViewNavigationType)navigationType
{
[self.loadingIndicator startAnimating] ;
[self.loadingIndicator setHidden:NO];
return YES;
}

-(void)webViewDidFinishLoad:(UIWebView *)webView
{
[self.loadingIndicator setHidden:YES];
[self.loadingIndicator stopAnimating] ;
}

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[self.loadingIndicator setHidden:YES];
[self.loadingIndicator stopAnimating] ;
 }

 - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
 }

 - (IBAction)button:(id)sender {

}
@end


Take a Activity Indicator in your view and place it in center of screen or webview.Default hide activity indicator.

Now, When you load webPage then show activity indicator until your webpage completely load.

-(void)webViewDidFinishLoad:(UIWebView *)webView1{
if (webView1.isLoading){
    return;
}
[self.activityView stopAnimating];
self.activityView.hidden = TRUE;

}