A Gray/White/Black Page Is Rendered
There may be times when a gray, white, or black page is displayed on a PDF. While there can be a lot of reasons why you’re experiencing this issue, the most common is improper use of view controllers.
For information on this topic, please read up on Apple’s Implementing a Container View Controller guide.
Simply put, adding the PDFViewController
’s view onto another view alone won’t work; you need to connect the controllers as well:
func displayContentController(_ content: UIViewController) { addChild(content) content.view.frame = frameForContentController() view.addSubview(currentClientView) content.didMove(toParentViewController: self) }
- (void)displayContentController:(UIViewController*) content { [self addChildViewController:content]; content.view.frame = [self frameForContentController]; [self.view addSubview:self.currentClientView]; [content didMoveToParentViewController:self]; }
For more information, refer to the objc.io article on View Controller Containment.