Problem in implementing Quick Look API
I want to implement QuickLook API for preview of pdf file. I made a view based app and in .h file I import QuickLook/QuickLook.h . in .m file I made the object of QLPreviewController inside viewDidLoad. After that i tried to make object of QLPreviewItem, but开发者_C百科 this gives error "QLPreviewItem undeclared". Plz help me if u can.
Thanx.
QLPreviewItem is not a class but a protocol. You must either use NSURLs to fill the API (NSURL conforms to QLPreviewItem) or create your own class of objects conforming to that protocol.
Your almost there!
the QLPreviewController need a QLPreviewControllerDataSource
implement <QLPreviewControllerDataSource>
and add two functions:
- (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller
{
return 1; //number of documents, usually you use a array with document url's
}
- (id <QLPreviewItem>) previewController: (QLPreviewController *) controller previewItemAtIndex: (NSInteger) index
{
return [NSURL fileURLWithPath:@"document.pdf"]; //other documents are supported too
}
Your see that the second method a QLPreviewItem returns (as you see it works with plain URL's too)
I hope I helped you a bit further
精彩评论