How can I get the thumbnail of a QuickLook Preview Item?


I'm previewing various documents using QLPreviewController. The controller has a "list view" option where it displays the image and title of all of the documents in the controller.

Standard QLPreview List View

How can I get that image so I can display it on a different screen?

I'm trying to make a "view file" screen where it shows all of the file details and a thumbnail preview. Then clicking the thumbnail would bring the user to the full preview.

File Detail Page


Answers:


In iOS, there isn't API for having the thumbnail of a file (like AppCoda-Image or AppCoda-PDF) but you can get an icon like AppCoda-Pages, AppCoda-Word, AppCoda-Keynote or AppCoda-Text.

// Create an `UIDocumentInteractionController` with the file URL.
let controller = UIDocumentInteractionController(url: <#URL#>)

// Get icon
_ = controller.icons[0]

This will return the icon but not the thumbnail.