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, read up on Apple’s Implementing a Container View Controller(opens in a new tab) 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)
}

For more information, refer to the objc.io article on View Controller Containment(opens in a new tab).