8

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?

Jeffrey Greenham
  • 1,382
  • 5
  • 16
  • 33
SG1
  • 81
  • 1
  • 3

1 Answers1

7

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.

Conrad Shultz
  • 8,748
  • 2
  • 31
  • 33