0

たくさん検索しましたが、ドキュメントフォルダからvfr-readerでPDFを開くことができません。

NSString *filePath = @"/Users/***/Library/Application Support/iPhone Simulator/5.0/Applications/F2B7E9DE-9996-4F05-BC81-2A2889B4F504/Documents/Number1.pdf";
ReaderDocument *document = [ReaderDocument withDocumentFilePath:filePath password:password];

if (document != nil)
{// document comes nil here

    ReaderViewController *readerViewController = [[ReaderViewController alloc] initWithReaderDocument:document];
    readerViewController.delegate = self; // Set the ReaderViewController delegate to self
    [self.navigationController pushViewController:readerViewController animated:YES];

}

filepathは正確にpdfファイルであると確信しています。

リーダーのサンプルコードでは、メインバンドルからPDFを開きます。しかし、私はリソースフォルダから開く必要があります。

ありがとう

4

4 に答える 4

1

私は同じ問題に直面しています。あなたも同じ問題を抱えているかもしれません。

ARC を使用していない場合は、ビルド面のすべての pdf リーダー ファイルに-fobjc-arcを書き込むだけです。それはあなたの問題を解決します。

于 2013-04-15T07:02:06.990 に答える
0

以下のコードのようにファイル名を指定する必要があります。直接指定しないでください。

NSArray *pathss = NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsPaths = [pathss objectAtIndex:0];
    NSString *filePaths = [documentsPaths stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",fileName]];
于 2013-02-09T11:32:30.727 に答える
0

文字列をハードコーディングする代わりに[[NSBundle mainBundle] bundlePath]andを使用する必要があります。stringByAppendingPathComponent:これは非常に恐ろしいことであり、iOS シミュレーターでしか機能しません。

于 2013-01-12T10:25:28.967 に答える