How to use QLPreviewPanel?

让人想犯罪 __ 提交于 2019-12-05 10:46:55

Check out the QuickLookDownloader code. It walks you through a couple of things you need to do to incorporate QLPreviewPanel into your code. Some of these include:

  1. Making your objects conform to the QLPreviewItem protocol - this tells Quick Look where to find the file you want to preview (and you are previewing files - you can't pass in custom data).
  2. Defining a data source and delegate for the QLPreviewPanel (if you're worked with NSTableViews before, this should be pretty familiar).
  3. Configuring the preview panel via the QLPreviewPanelController protocol (where you assign the data source and delegate).
  4. Displaying shared preview panel.

Items 1-3 are handled in the MyDocument class of the sample code. Toggling the display is mostly handled in the AppDelegate class. There's also support in the DownloadsTableView class that toggles the QLPreviewPanel via the space key, a la the Finder.

I am just looking at this myself. And have found that Apple provide a good guide with examples in the Docs, Also there is a good example code and files here -> animgifqlgen

I am using the Enriched HTML method, which seems to be working for what I need.

The idea is to Use what ever code you would normally use to parse the info on the file. And use html for the layout and embedding the parsed info,the html is then displayed within the QL Panel. A lot of the normal html code works like size width length,bgcolor,src ...

The example will show how to write the code including the html parts.Which uses a NSMutableString and its appendString and appendFormat: to build the html.

I have not tried the other methods yet.

For testing I just configured the Document Content Type UTIs in the plist and the put a copy of the built product (the plugin) in my /Users/username/Library/QuickLook/ folder.

You may have to create the Folder.

Note that when you want to replace the plugin in the QuickLook folder by drag and dropping a new copy in the folder, it may be in use. Just put the old one in the trash. I also found it helped quitting the Quick Look Helper process using the Activity Monitor app. Doing so made sure I was seeing the results from the New version plugin rather than the old one still in memory. ( I sure someone will tell me I am doing bad ;-) )

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!