Rendering PDF in UIWebView iOS 8, causes a black border around PDF(在 UIWebView iOS 8 中渲染 PDF,导致 PDF 周围出现黑色边框)
问题描述
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];
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?
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];
}
}
Turn off WebKitDiskImageCacheEnabled and the black border goes away:
In applicationDidFinishLaunchingWithOptions add the following lines:
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDiskImageCacheEnabled"];
[[NSUserDefaults standardUserDefaults] synchronize];
这篇关于在 UIWebView iOS 8 中渲染 PDF,导致 PDF 周围出现黑色边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 UIWebView iOS 8 中渲染 PDF,导致 PDF 周围出现黑色边框
基础教程推荐
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
