简体   繁体   中英

iOS Swift PDFViewer native toolbar

I want to create a download button for my PDFView , but I was only able to do it by adding a Toolbar with a Button to the same ViewController that contained the PDFView and I added the download function to that button.

I used UIActivityViewController . The Button on the Toolbar used this to show the View where the user can download the PDF .

let activityController = UIActivityViewController(activityItems: 
[self.pdfDownloadableData], applicationActivities: nil)

Is there any way where I can do the same without adding a Toolbar and a Button manually to the ViewController ? Does the PDFViewer has some native way to add this Button to itself somehow?

Thank you for your help!

You can go with UIDocumentInteractionController

A view controller that previews, opens, or prints(download) files whose file format cannot be handled directly by your app.

Use this class to present an appropriate user interface for previewing, opening, copying, or printing a specified file. For example, an email program might use this class to allow the user to preview attachments and open them in other apps.

After presenting its user interface, a document interaction controller handles all interactions needed to support file preview and menu display.

You can also use the delegate to participate in interactions occurring within the presented interface. For example, the delegate is notified when a file is about to be handed off to another application for opening. For a complete description of the methods you can implement in your delegate, see UIDocumentInteractionControllerDelegate .

Also check with QLPreviewController while handling Document related tasks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM