【发布时间】:2010-12-08 12:22:08
【问题描述】:
我正在尝试将 .docx 文件加载到 uiwebview 中并显示它。要将文档加载到 webview 中需要几分之一秒,所以我可以在内容出现在屏幕上之前看到一个白色的空白屏幕。我不想在加载时看到那个白屏,我想做一些动作,比如活动指示器或更改背景。我该如何实现这一点,请帮助我。 这是我的代码;
-(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];
}
并在 viewdidload 中调用上述方法:
[self loadDocument:@"ADVISORuser_updated.docx" inView:self.webView];
甚至正在实现一个委托方法来更改背景,但委托没有执行
- (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];
}
}
谁能帮帮我..
【问题讨论】:
标签: iphone objective-c cocoa-touch uiwebview