Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos 如何在cocoa应用程序中使用PDFView?_Macos_Cocoa_Xcode4_Pdfview - Fatal编程技术网

Macos 如何在cocoa应用程序中使用PDFView?

Macos 如何在cocoa应用程序中使用PDFView?,macos,cocoa,xcode4,pdfview,Macos,Cocoa,Xcode4,Pdfview,我现在正在研究cocoa,所以对mac开发有点陌生。 我想从我的服务器打开PDF。使用PDFView,这可能吗? 如果有人在这方面指导我,那将对我非常有帮助。 是否有在PDFView中打开PDF文件的示例代码 提前谢谢 我得到了答案 至少为我工作……) 我得到了答案 至少为我工作……) Swift版本(不要忘记导入石英模块) Swift版本(不要忘记导入石英模块) Swift 3.0版本:) Swift 3.0版本:) NSString *urlStr = [[NSBundle mainBund

我现在正在研究cocoa,所以对mac开发有点陌生。
我想从我的服务器打开PDF。使用
PDFView
,这可能吗?
如果有人在这方面指导我,那将对我非常有帮助。
是否有在PDFView中打开PDF文件的示例代码

提前谢谢

我得到了答案

至少为我工作……)

我得到了答案

至少为我工作……)

Swift版本(不要忘记导入石英模块)

Swift版本(不要忘记导入石英模块)

Swift 3.0版本:)

Swift 3.0版本:)

NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"1.pdf" ofType:nil];
NSURL *url = [NSURL fileURLWithPath:urlStr];
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:url];
[pdfView setDocument:pdfDoc];
    guard let docPath = NSBundle.mainBundle().pathForResource("1", ofType: "pdf") else { return }

    let docURL = NSURL.fileURLWithPath(docPath)
    let pdfDocument = PDFDocument(URL: docURL)
    guard let docPath = Bundle.main.path(forResource: "1", ofType: "pdf") else { return }

    let docURL = NSURL.fileURL(withPath: docPath)
    let pdfDocument = PDFDocument(url: docURL)
    uxPdf.document = pdfDocument