1

このコードを使用してサーバーからpdfファイルをダウンロードしています。

   NSString *urlString = @"https://developer.apple.com/library/ios/documentation/uikit/reference/UILabel_Class/UILabel_Class.pdf";

   NSURL *url = [NSURL URLWithString:urlString];

   ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
   [request setDownloadDestinationPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:@"UILabel.pdf"]];
   [request setDelegate:self]; 
   [request startAsynchronous];

ダウンロード機能は正常に動作しています。しかし、ダウンロードしたPDFをCGPDFDocumentRefで表示する必要があります。

前もって感謝します。

4

1 に答える 1

3

PDF をダウンロードしたら、その PDF ファイルをドキュメント ディレクトリに保存し、そこから PDF を取得して、以下のように CGDocumentref を使用して表示します。

  CFURLRef pdfURL = (CFURLRef)[[NSURL alloc] initFileURLWithPath:[documentsDirectory stringByAppendingPathComponent:source]];
        //file ref
        CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((CFURLRef) pdfURL);
于 2012-03-12T12:02:31.440 に答える