在UIWebView iOS 8中渲染PDF会导致PDF周围出现黑色边框 [英] Rendering PDF in UIWebView iOS 8, causes a black border around PDF
问题描述
在iOS 8中,将.PDF渲染为 UIWebview
时,显示的是黑色边框和背景(不是整个背景视图)。请注意,这不是UIWebview背景设置为:
In iOS 8, when rendering a .PDF into a UIWebview
there is a black border and background around the PDF displayed (not the whole background view). Note this is not the UIWebview background which is set to:
myWebView.opaque = NO;
myWebView.backgroundColor = [UIColor clearColor];
< iOS8,(.PDF周围没有黑色边框彩色背景)
This is not present in < iOS8, (no black bordering coloured background around the .PDF)
其他有经验的人可以对此有所了解吗?
Anyone else experienced this who could shed some light on this?
我将我的PDF加载到Web视图中就像这样..
Im loading my PDF into the Web view like so..
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (self.pdfData != nil && self.viewHasUnloaded == YES) {
self.viewHasUnloaded = NO;
[self.webView loadData:self.pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
}
}
推荐答案
转关闭WebKitDiskImageCacheEnabled并且黑色边框消失:
Turn off WebKitDiskImageCacheEnabled and the black border goes away:
在applicationDidFinishLaunchingWithOptions中添加以下行:
In applicationDidFinishLaunchingWithOptions add the following lines:
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDiskImageCacheEnabled"];
[[NSUserDefaults standardUserDefaults] synchronize];
这篇关于在UIWebView iOS 8中渲染PDF会导致PDF周围出现黑色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!