iOS pdf file in webview to load a black screen problem

Disclaimer: This article is a blogger original article, reproduced, please indicate the source of the article. https://blog.csdn.net/SunFlowerInRain/article/details/78677182

Write pictures described here
Project development process, after the completion of the process of loading a pdf file, often black screen appears;
because webview call -webViewDidFinishLoad:after responsible for rendering UIWebPDFView pdf file has not finished loading, all want to get rid of the black background may be in -(void)viewDidLayoutSubviewsor

- (void)webView:(WKWebView *)webView 
didFinishNavigation:(WKNavigation *)navigation

Re-set the background color is white UIWebPDFView

- (void)webView:(WKWebView *)webView 
didFinishNavigation:(WKNavigation *)navigation 
{
   UIView *v = webView;
    while (v) {
        v.backgroundColor = [UIColor whiteColor];
        v = [v.subviews firstObject];
    }
}

Reference Links: https://stackoverflow.com/questions/45626151/ios-wkwebview-load-local-pdf-files-some-pages-become-black

Guess you like

Origin blog.csdn.net/SunFlowerInRain/article/details/78677182