ios - UIWebView loadRequest复用给出闪烁效果

标签 ios ipad uiview uiwebview uiwebviewdelegate

我有多个 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/

相关文章:

ios - timeIntervalSinceNow 用于获取耗时值的用法

memory - iPad 收到内存使用不足的内存警告

objective-c - 导航栏重新出现在欢迎屏幕上。如何永久隐藏它?

ios - 按下按钮时的 UIView 动画 - 第一次尝试时不可见

iphone - iOS - UIView 是否属于 UIViewController?

ios - ios 8.4模拟器在xcode 6.4中非常大吗?

ios - 使用导航 Controller 后选项卡栏项目图标丢失

iphone - 在委托(delegate)方法中访问单元格的属性

ios - 带有 UIDatePicker subview 的 UIActionSheet 有一个小的透视区域

iphone - 错误 : Symbol not found: ___CFObjCIsCollectable