2

Quick question. Does anyone know if there is a way you can disable the UIDocumentInteractionController from presenting the menu to open the document in a different application? (The button in the top right) Or at least hide that button? I thought I remembered seeing that you could do that somewhere....

ie. Is there like a docController.menuButton.hidden = YES or something like that?

Thanks.

gabaum10
  • 3,769
  • 3
  • 48
  • 89

2 Answers2

1

I think you need to look at a Quick Look controller, not a UIDocumentInteractionController.

Benjamin Mayo
  • 6,649
  • 2
  • 26
  • 25
  • Using a `QLPreviewController` doesn't make it much easier https://stackoverflow.com/a/69454052/1049134 – Rivera Oct 05 '21 at 16:23
0

This is not trivial and may break with every iOS update.

First you'll need to get the underlying QLPreviewController that is created by the UIDocumentInteractionController.

For that implement UIDocumentInteractionControllerDelegate's documentInteractionControllerWillBeginPreview:

public func documentInteractionControllerWillBeginPreview(_ controller: UIDocumentInteractionController)
{
    DispatchQueue.main.async { // Use async or you won't get anything
        let aQLPreviewController = self.documentInteractionControllerViewControllerForPreview(controller).presentedViewController

        // Next dig the QLPreviewController hierarchy
    }
}

Now that you have the underlaying QLPreviewController follow the instructions from this answer https://stackoverflow.com/a/69454052/1049134

Rivera
  • 10,792
  • 3
  • 58
  • 102