2011-11-02 5 views
0

私は今、ココアに取り組んでいます。
私のサーバーからPDFを開きたいです。これはPDFViewで可能ですか?
誰かが私のためにこれを案内してくれれば、とても役に立ちます。
PDFViewでPDFファイルを開くサンプルコードはありますか?PDFViewをココアアプリで使用するには?

ありがとうございます。

は、少なくとも私のために働いて、私は答えました

答えて

4

.. :)

NSString *urlStr = [[NSBundle mainBundle] pathForResource:@"1.pdf" ofType:nil]; 
NSURL *url = [NSURL fileURLWithPath:urlStr]; 
PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:url]; 
[pdfView setDocument:pdfDoc]; 
3

スウィフトバージョン(クォーツモジュールをインポートすることを忘れないでください)

guard let docPath = NSBundle.mainBundle().pathForResource("1", ofType: "pdf") else { return } 

    let docURL = NSURL.fileURLWithPath(docPath) 
    let pdfDocument = PDFDocument(URL: docURL) 
1

スウィフト3.0バージョン:)

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 
関連する問題