I am loading some file from document directory using UIWebView. I have set the delegate of UIWebView and I am responding to 2 methods of delegate that is
webViewDidStartLoad
and webViewDidFinishLoad
I am receiving the webViewDidStartLoad
But I am not receiving webViewDidFinishLoad
method.
Below is the code:
@interface MyView: UIViewController <UIWebViewDelegate> {
UIWebView *webView;
}
@property (nonatomic, retain) UIWebView *webView;
========================= Class ===========================
-(void)viewDidLoad {
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
mWebView = [[UIWebView alloc] initWithFrame:webFrame];
mWebView.delegate = self;
mWebView.scalesPageToFit = YES;
[self.view addSubview:mWebView];
NSString *path = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", pathString]];
[mWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]] ];
}
// Delegate methods
-(void)webViewDidStartLoad:(UIWebView *)webView {
NSLog(@"start");
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {
NSLog(@"finish");
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
NSLog(@"Error for WEBVIEW: %@", [error description]);
}
Please let me know what is going wrong. I am not getting any error in didFailLoadWithError delegate method.
Note:- the file that I am loading are huge say 3 MB.
Thanks
=============EDITED==================
As I was loading very huge File the delegate was coming after very long duration that I was not able to notice but for small files everything is working fine
Best Answer
Hey probably you should do this,
Call removeLoadingView method in the following UIWebViewDelegate methods
The showActivityIndicator method
The removeLoadingView method