我有多个 pdf 文件。根据用户输入,我正在使用 UIWebView 加载 pdf。在第一次 loadRequest 时,它会正确加载 pdf。从第二次调用 LoadRequest 开始,它在加载新 pdf 时显示出一些闪烁效果。这意味着开始模糊显示内容并在几秒钟内慢慢正确显示内容。
下面的代码片段:
- (void) loadDocument: (NSString *) documentName
{
NSString * path = [[NSBundle mainBundle] pathForResource: documentName ofType: self.docType];
NSURL * url = [NSURL fileURLWithPath: path];
request = [NSURLRequest requestWithURL: url];
[PdfWebView loadRequest: request];
}
- (void) loadNewDoc:(int)segIndex
{
switch (mPageIndex)
{
case 0:
[self loadDocument:@"PDF_0"];
break;
case 1:
[self loadDocument:@"PDF_1"];
break;
case 2:
[self loadDocument:@"PDF_2"];
break;
default:
break;
}
}
最佳答案
您可以在开始新请求之前清除 WebView ,方法是使用
[yourwebview loadHTMLString:@"<html><head></head><body></body></html>" baseURL:nil];
甚至
[yourwebview stringByEvaluatingJavaScriptFromString:@"document.open();document.close();"];
这可能会消除闪烁效果
关于ios - UIWebView loadRequest复用给出闪烁效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11222137/