Get notifications for unlocked password-protected PDFs

If you initialize a PDFViewController with a password-protected document, the documentViewController property is nil until the document is unlocked.

You can implement PDFViewControllerDelegate.pdfViewController(_:didChange:error:) to get the non-nil document view controller when the document is unlocked, like so:

let pdfController = PDFViewController(document: lockedDocument)
pdfController.delegate = self
...
func pdfViewController(_ pdfController: PSPDFViewController, didChange controllerState: PSPDFControllerState, error: Error?) {
if controllerState == .default {
if let layout = pdfController.documentViewController?.layout as? ContinuousScrollingLayout {
layout.fillAlongsideTransverseAxis = true
}
}
}