Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically quicklook images in Mac OS X

I'm developing an application for Mac OS X in Xcode, and I'm trying to implement a button that opens an image in Quicklook mode (like when you select an image in Finder and press <space>).

I would like this to work like Skype for Mac when you click on the little round "eye" icon next to a file that was downloaded during a chat.

Any advice on how to achieve this?

like image 689
bgh Avatar asked Oct 28 '12 18:10

bgh


1 Answers

After revisiting this question, I finally came across a resource that led me in the right direction to solving the problem.

Apple's Quick Look Programming Guide seems to be very focused on the implementation of generators, which was not what I was interested in. This document does not seem to have a section that explains how to display a QuickLook preview from inside of your app. However, I came across an example project (QuickLookDownloader) that very nicely illustrates how it's done.

You basically use the application's shared QLPreviewPanel object. You make the QLPreviewPanel the key window by calling its makeKeyAndOrderFront: method. You then accept (and release) the QLPreviewPanel via the methods of the QLPreviewPanelController protocol. These methods are called on the first object on the responder chain that responds to it when the QLPreviewPanel becomes key. You must also implement the QLPreviewPanelDataSource and QLPreviewPanelDelegate protocols and assign the delegates to the QLPreviewPanel.

There are a few steps that need to be taken, but the example QuickLookDownloader project illustrates it nicely.

like image 100
bgh Avatar answered Sep 28 '22 02:09

bgh