Jonathan.
Jonathan.

Reputation: 55604

How to use QLPreviewPanel?

I have an app which can download images and text, I want to use the QLPreviewPanel to give a preview of this. However the delegate and datasource implementation has me confused. I just want to pass an image or string and have it displayed? (is QLPreviewPanel even the right thing to use here?)

Upvotes: 0

Views: 1523

Answers (1)

jscs
jscs

Reputation: 64022

There's not much to it. Take a look at Apple's sample project Quick Look Downloader; the file MyDocument.m has the data source and delegate methods.

The data source methods are just like table view data source methods:

- (NSInteger)numberOfPreviewItemsInPreviewPanel:(QLPreviewPanel *)panel
{
    return [myCollectionOfItems count];
}

- (id <QLPreviewItem>)previewPanel:(QLPreviewPanel *)panel previewItemAtIndex:(NSInteger)index
{
    return [myCollectionOfItems objectAtIndex:index];
}

You can skip implementing a delegate if you don't need to customize the behavior of the panel.

Upvotes: 2

Related Questions