本文介绍了如何将QLPreviewPanel显示作为可可中的弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想制作一个可以像聚光灯搜索实现一样显示为Popover的Popover吗?我只能使用传统方式在中心显示一个Quicklook窗口,但我想做这样的事情:

I would like to make a Popover that can show as a popover like the spotlight search implementation? I can only use traditional way to show a Quicklook window on the centre, but I would like to make something like this:

我该怎么做?谢谢.

推荐答案

这可以通过创建 QLPreviewView 实例嵌入在 NSPopover .

This can be achieved by creating a QLPreviewView instance embedded within a NSPopover.

然后,创建一个符合QLPreviewItem协议的NSObject子类,并像使用传统的QuickLook QLPreviewPanel一样在QLPreviewView上设置previewItem属性.

Then, create a NSObject subclass that conforms to the QLPreviewItem protocol and set the previewItem property on your QLPreviewView like when working with the traditional QuickLook QLPreviewPanel.

QLPreviewView *view = [[QLPreviewView alloc] initWithFrame:NSMakeRect(0, 0, 800, 100) style:QLPreviewViewStyleNormal];

JPQuickLookItem *item = [[JPQuickLookItem alloc] init];
item.previewItemURL = [NSURL fileURLWithPath:@"/Users/josh/Desktop/Test.png"];
item.previewItemTitle = @"Test.png";
view.previewItem = item;

我已经创建了一个示例Swift实现此处.

这篇关于如何将QLPreviewPanel显示作为可可中的弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-20 23:38