Rendering PDF in Uiwebview iOS 8, Causes a Black Border Around PDF

Rendering PDF in UIWebView iOS 8, causes a black border around PDF

Turn off WebKitDiskImageCacheEnabled and the black border goes away:

In applicationDidFinishLaunchingWithOptions add the following lines:

[[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"WebKitDiskImageCacheEnabled"];
[[NSUserDefaults standardUserDefaults] synchronize];

Black border around PDF in UIWebView, how to remove with Swift

I think that your suggested solution is not enough even in Objective-C.
Please see Rendering PDF in UIWebView iOS 8, causes a black border around PDF.

And , I fixed this issue in Swift.
Put below code into the main UIViewController.

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

clearPDFBackground(self.webView)
}

func clearPDFBackground(webView: UIWebView) {
var view :UIView?
view = webView as UIView

while view? != nil {
if NSStringFromClass(view?.dynamicType) == "UIWebPDFView" {
view?.backgroundColor = UIColor.clearColor()
}

view = view?.subviews.first as UIView?
}
}

iOS WKWebView loading PDF data in DarkMode has black background around PDF document

Try to use UIUserInterfaceStyle flag with Light value in app's .plist file to avoid automatically changing colors in a whole app. If you want to do it for certain UIViewController or UIView - just override overrideUserInterfaceStyle property with UIUserInterfaceStyleLight or UIUserInterfaceStyleDark value.

Page numbers inside UIWebView when loading PDF

Found out that page numbers where hidden underneath the navigation bar (see picture with navigation bar hidden). Not sure why though, because the scroller ended perfectly underneath the navigation bar. My solution will be to hide navigation bar and show it only when user taps or scrolls up.

Sample Image



Related Topics



Leave a reply



Submit