简体   繁体   中英

Make a Quick Look NSView in Swift

I'm trying to add this feature to my app: when pushing a certain button, open a quick look view of a certain file.

I saw this: Use Quick Look inside a Swift cocoa application to preview audio files , but the error written in the comments shows up and the app crashes after trying to go back and forth between files.

Apple's class reference of QLPreviewPanel is quite empty.

Which is a correct implementation? What is wrong in the answer in the question I linked?

Apple's class reference of QLPreviewPanel is quite empty.

They have a lot of bugs currently. You can "View page source" in your browser, or use Xcode built-in help, it's pretty good.

Which is a correct implementation?

It looks like someone has already done it with Swift. I'm not sure if that's the full implementation.

What is wrong in the answer in the question I linked?

QLError() [...] called while the panel has no controller is decrypted this way: some class in the responder chain (your NSView or NSWindow should be there already, unless you have a very complex structure) must respond to acceptsPreviewPanelControl: and two other QLPreviewPanelController methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM