2012-03-16 149 views
3

我想在Cocoa應用程序中打開PDF。我嘗試使用預覽來打開PDF。如何在Cocoa應用程序中打開PDF

[[NSWorkspace sharedWorkspace] openURL:[NSURL fileURLWithPath:@"filepath"]]; 

但是我想打開附加到窗口的PDF,類似於Xcode的幫助窗口。你如何使用PDFKit實現這一點?

回答

4

我進口QuartzFrameWork,並在XIB加入PDFView。以下代碼爲我完成了這項工作:

NSURL *url = [NSURL fileURLWithPath:@"filePath"] 
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:url]; 
[_pdfView setDocument:pdfDoc]; 
相關問題