0

我用过这段代码:

NSURL *documentURL= [NSURL fileURLWithPath:aStrPrintPdfPath isDirectory:NO];
PSPDFDocument *document = [PSPDFDocument documentWithURL:documentURL];

PSPDFViewController *pdfController = [[PSPDFViewController alloc] initWithDocument:document];
pdfController.pageTransition = PSPDFPageTransitionCurl;
pdfController.renderingMode = PSPDFPageRenderingModeFullPageBlocking;
[pdfController setUpdateSettingsForRotationBlock:^(PSPDFViewController *aPDFController, UIInterfaceOrientation toInterfaceOrientation) {
    // conditionally set depending on rotation
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
        aPDFController.pageMode = PSPDFPageModeDouble;
    }  else {
        aPDFController.pageMode = PSPDFPageModeSingle;
    }

}];

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pdfController];
[self presentViewController:navController animated:YES completion:NULL];
pdfController.title = @"";
[pdfController release];
[navController release];

现在problem是否需要30 to 50 seconds给出这些错误:错误:NSError *PSPDFError(NSInteger, NSString *_ strong, NSError * _autoreleasing *)/35 Error 210: documentRef is nil; cannot get pageReffor page 1.hanging my UI completetly然后openspdfControllernothing

4

2 回答 2

2

这是 PSPDFKit 的主要开发者。

当您得到“documentRef is nil; cannot get pageRef”时 - 这意味着用于创建 PSPDFDocument 的 PDF 源无效。检查isValid文档上的属性以编程方式对此进行测试。

我不确定您是什么版本,但至少 3.x 不会阻塞您的 UI 线程,而只是显示一个空视图控制器,等待您设置不同的文档。

于 2013-10-12T14:22:06.287 回答
0

以前从未使用过 PSPDFViewController ,但是从您收到的错误来看,可能是内存可能在 init 中管理的情况。

这些完全是粗略的建议,但只是想帮助你:

try removing your pdfcontroller release or adding an autorelease at the end of your init (this probably won't have an effect if you add the autorelease however)

try creating a @property for your pdfcontroller in your header file and releasing/managing the memory in your viewdidunload method (and maybe even dealloc).
于 2013-10-08T04:53:00.340 回答