Josh Paradroid
Josh Paradroid

Reputation: 1414

Is it possible to display a UIDocumentInteractionController in a container?

I have a UIViewController within a container view. The view controller displays a PDF in a UIDocumentInteractionController like so:

let documentInteractionController = UIDocumentInteractionController(url: pdfUrl)
documentInteractionController.delegate = self
documentInteractionController.presentPreview(animated: true)

The UIDocumentInteractionController displays itself modally. I'd like it to be displayed within the container. Is this possible?

Upvotes: 1

Views: 1096

Answers (1)

David Brodegard
David Brodegard

Reputation: 36

Responding a little late to this but I had the same question recently- I'm not sure about your full navigation setup, but returning the navigation controller in the delegate method below will present the preview within the navigation stack. (returning anything else will present the default modal view)

Documentation here: https://developer.apple.com/reference/uikit/uidocumentinteractioncontrollerdelegate/1616799-documentinteractioncontrollervie

func documentInteractionControllerViewControllerForPreview(_ controller: UIDocumentInteractionController) -> UIViewController {
    //return self to present modally
    //return nav controller to push document preview into the stack
    return self.navigationController!
}

Upvotes: 2

Related Questions