This is for a macOS app, here's my code for previewing PDF files using Quicklook:
import Quicklook
struct ContentView: View {
@State var url: URL?
var body: some View {
VStack {
Button("Open"){
showOpenPanel()
}.quickLookPreview($url)
}
.padding()
}
func showOpenPanel() {
let openPanel = NSOpenPanel()
openPanel.allowedFileTypes = ["pdf"]
openPanel.allowsMultipleSelection = false
openPanel.canChooseDirectories = false
openPanel.canChooseFiles = true
openPanel.runModal()
url = openPanel.url
}
}
How do I have the quicklook preview file be shown inside my content view instead of launching itself in a separate window?
