Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Quicklook embedded preview

From the docs for quicklook:

"The consumer portion of Quick Look has three components: a document reader (consisting of a custom view and panel), display bundles for that reader, and an SPI to enable communication with the client. Each of these components has a specific role to play in support of the consumer:

Document reader—Quick Look implements a view (NSView) and panel (NSPanel) customized for displaying document previews. Along with the preview content, the view might include (at the client’s option) controls for manipulating the preview, such as page-forward, page-backward, start playing, rewind, and text-search. A client application can embed this view in its user interface if it chooses. The Quick Look panel contains a Quick Look view and various controls that let the user take some action with the preview, such making the preview image full-screen or starting a slideshow."

I have been poring through all the docs and examples for quicklook and I don't see either:

  1. A definition of any sort of "Document reader" component or way to access it.
  2. Any sort of SPI as such that would show how to consumer quicklook
  3. Any direct access to the NSView used by quicklook to display previews.

All I want to to do as the docs say: embed quicklook's view in my own hierarchy rather than in the Panel. The panel of course has abundant documentation. Has anyone successfully used Quicklook in this manner before?

like image 277
SG1 Avatar asked Dec 17 '10 21:12

SG1


People also ask

How do I use QLPreviewController?

You can present a QLPreviewController modally by calling presentViewController:animated:completion: from a presenting UIViewController , or you can push it into view using a UINavigationController . The preview includes a title taken from the last path component of the item URL.

Where is quick look on iPhone?

1) Open the Shortcuts app on your iPhone or iPad with iOS 13 or later. 2) Tap the My Shortcuts tab at the bottom. 3) Tap Create Shortcut or hit the Plus button. 4) Type “Quick Look” in the search field inside the lefthand column.


1 Answers

The class you are looking for is QLPreviewView, part of Quartz.framework. It's a public class (introduced in Lion, I believe). Unfortunately, the docs team apparently hasn't yet released its documentation, which is probably why you couldn't find it. The official docs are now available.

The short, short version is that you create it the way you would any other view, and set its previewItem to an id <QLPreviewItem> that you supply. The <QLPreviewItem> protocol is documented. E.g.

QLPreviewView *pv = [[QLPreviewView alloc] initWithFrame:frame
                                                   style:QLPreviewViewStyleNormal];
[pv setPreviewItem:item];
[myView addSubview:pv];
[pv release];

That's the basic concept, YMMV.

Its operation is thoroughly covered in the 2011 WWDC session "System-wide Previews on Mac OS X and iOS" (or something to that effect). You should be able to get the video if you are a paid member of either the Mac OS X or iOS developer programs.

like image 197
Conrad Shultz Avatar answered Oct 01 '22 14:10

Conrad Shultz