Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
792 views
in Technique[技术] by (71.8m points)

swift - Set QuickLook window size when previewing with QLPreviewingController.preparePreviewOfFile

I am writing a QuickLook plugin for macOS and everything works, except that I can't set programmatically the window size of the preview.

It starts with 800x600, no matter what I do in the XIB and/or in the code, before and/or after the call to the completionHandler of preparePreviewOfFile.

Other file types, handled by the default plugin, adapts the preview window size to the content of the file. I would like to do just that.

The preview window is resizable by the user and, once resized, keeps the new size when I select another file in the Finder, to go back to 800x600 if I close it and reopen it on a file handled by my plugin.

What am I missing?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

QLPreviewingController should set its preferredContentSize so that the window can be sized accordingly.

https://developer.apple.com/documentation/appkit/nsviewcontroller/1434409-preferredcontentsize


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...