Loading a document into a Webview
Am trying to load a .docx file into the uiwebview and am displaying it.To load开发者_如何学Go the document into the webview it takes some fraction of seconds so i can see a white blank screen before the content can appear on the screen.I don't want to see that white screen while loading instead of that i want to do some actions like activity indicator or changing the background.How can i achieve this please help me. Here is my code;
-(void)loadDocument:(NSString*)documentName inView:(UIWebView*)webViews
{
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 416)];
isWebviewLoaded=YES;
webView.delegate=self;
webView.alpha=0;
NSString *path = [[NSBundle mainBundle] pathForResource:@"SKIN ADVISORuser_updated.docx" ofType:nil];
//NSString *path = [[NSBundle mainBundle]pathForResource:@"UserGuidelines3.html" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webViews loadRequest:request];
}
and in viewdidload am calling above method:
[self loadDocument:@"ADVISORuser_updated.docx" inView:self.webView];
Even am implementing a delegate method to change the background but delegate is not executing
- (void)webViewDidFinishLoad:(UIWebView *)webViewload {
if (isWebviewLoaded)
{
isWebviewLoaded = NO;
webView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"Instructions Screen Background light_PNG.png"]];
[UIView beginAnimations:@"webView" context:nil];
webView.alpha = 1.0;
[UIView commitAnimations];
}
}
Please can anyone help me..
before loadRequest u could create UIActivityIndicator object and start it by calling start method
and in webView delegate didFinishLoading: & didFailwithError method suspend the activity indicator
- (void)webViewDidFinishLoad:(UIWebView *)webViewload {
will be called only if you have set the delegate for the webView (in the xib &.h file)
精彩评论