0

I'm showing a pdf file inside a UIDocumentInteractionController, like this:

let docController = UIDocumentInteractionController(url: documentsURL)
    let url = NSURL(string:"itms-books:");
    if UIApplication.shared.canOpenURL(url! as URL) {
        docController.delegate = self
        docController.presentPreview(animated: true)
    }

I need to automatically scroll to the last page when the controller is shown, is there a way to do that? I didn't find one. Thanks to anyone who will send help!

Silvia
  • 204
  • 1
  • 2
  • 7

1 Answers1

1

I am afraid there is not a straight forward solution for this, even the documentation says it's a UIViewController but Xcode shows it is inherited from NSObject. I'd recommend either rendering the PDF on a WKWebView or a UIScrollView. This will give you a room to wiggle.

Ashraf Tawfeeq
  • 3,036
  • 1
  • 20
  • 34
  • Thank you so much, you confirmed my sad hypothesis! :( The point is: I need to show the pdf in a modal view, I previously used a WebView and worked perfectly but I need the user to be able to at least save the file..any hint for this? Thanks again – Silvia Jun 03 '20 at 09:56
  • 1
    Maybe a custom button with a share option and you can use `UIActivityViewController` to do the trick for you. – Ashraf Tawfeeq Jun 03 '20 at 10:00
  • yeah I was thinking about a custom navigation bar similar to that one of the UIDocumentInteractionController. Last trial with UIDocumentInteractionController: have you figured out what annotations are for? – Silvia Jun 03 '20 at 10:11
  • 1
    I believe they are used for the options menu so other apps can extract a meta data like information to better handle it if they were used as a share option. – Ashraf Tawfeeq Jun 03 '20 at 10:45