FastPDFkit自定义类问题

时间:2015-06-19 10:46:15

标签: ios objective-c fastpdfkit

我正在使用FastPDFkit - 第三方iOS库来渲染PDF并执行一些自定义操作,如保存,收藏夹,电子邮件等。 很久以来,我一直在使用它的32位版本。

现在,我想将其升级到64位。我试图整合新的FastPDFkit框架。我用库建议的控制器制作了一个小型PoC。它的工作正常如下:

   -(IBAction)actionOpenPlainDocument:(id)sender{
    /** Set document name */
    NSString *documentName = @"Manual"; // Manual indicates catalog name

    /** Get temporary directory to save thumbnails */
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);

    /** Set thumbnails path */
    NSString *thumbnailsPath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",documentName]];

    /** Get document from the App Bundle */
    NSURL *documentUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:documentName ofType:@"pdf"]];

    /** Instancing the documentManager */
    MFDocumentManager *documentManager = [[MFDocumentManager alloc]initWithFileUrl:documentUrl];

    /** Instancing the readerViewController */
    ReaderViewController *pdfViewController = [[ReaderViewController alloc]initWithDocumentManager:documentManager];

    /** Set resources folder on the manager */
    documentManager.resourceFolder = thumbnailsPath;

    /** Set document id for thumbnail generation */
    pdfViewController.documentId = documentName;

    /** Present the pdf on screen in a modal view */
    [self presentViewController:pdfViewController animated:YES completion:nil];

    /** Release the pdf controller*/
   // [pdfViewController release];
}

此代码适用于默认组件。 在这里,ReaderViewController是由FastPDFkit建议的控制器,用于打开PDF。

在FastPDFkit头文件中,我检查ReaderViewController是否来自MFDocumentViewController。  像这样:

@interface ReaderViewController : MFDocumentViewController <MFDocumentViewControllerDelegate

注意:ReaderViewController和&amp; MFDocumentViewController是FastPDFkit框架,我只有.h文件。

现在,我使用iPhonePDFViewController创建了一个自定义类。

并尝试使用它进行类似的操作

@interface iPhonePDFViewController : MFDocumentViewController <MFDocumentViewControllerDelegate

并在实施中:

iPhonePDFViewController *viewController =  [[iPhonePDFViewController alloc] initWithDocumentManager:documentManager];

            viewController.documentName = @"Manual";//I took this PDF from some other way.

            documentManager.resourceFolder = thumbnailsPath;
            viewController.documentId = documentName;

            [self.navigationController pushViewController:viewController animated:YES];

但它正在崩溃说:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x030b9746 __exceptionPreprocess + 182
    1   libobjc.A.dylib                     0x04428a97 objc_exception_throw + 44
    2   CoreFoundation                      0x02fafc93 -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 451
    3   CoreFoundation                      0x02fc3b7b +[NSDictionary dictionaryWithObjects:forKeys:count:] + 75
    4   CatalogApp                    0x00249e4b priorityForOffset + 41190
    5   CatalogApp                    0x00247f34 priorityForOffset + 33231
    6   CatalogApp                    0x000d93e8 -[iPhonePDFViewController viewDidLoad] + 72
    7   UIKit                               0x00eeada4 -[UIViewController loadViewIfRequired] + 771
    8   UIKit                               0x00f227bd -[UINavigationController _layoutViewController:] + 42
    9   UIKit                               0x00f22d2c -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 235
    10  UIKit                               0x00f22e30 -[UINavigationController _startTransition:fromViewController:toViewController:] + 90
    11  UIKit                               0x00f23dd5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 669
    12  UIKit                               0x00f24a51 -[UINavigationController __viewWillLayoutSubviews] + 57
    13  UIKit                               0x0109e750 -[UILayoutContainerView layoutSubviews] + 213
    14  UIKit                               0x00e1957a -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 668
    15  libobjc.A.dylib                     0x0443e771 -[NSObject performSelector:withObject:] + 70
    16  QuartzCore                          0x021bfe47 -[CALayer layoutSublayers] + 144
    17  QuartzCore                          0x021b3925 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 403
    18  QuartzCore                          0x021b377a _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    19  QuartzCore                          0x0210fc52 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
    20  QuartzCore                          0x021110e5 _ZN2CA11Transaction6commitEv + 487
    21  QuartzCore                          0x021117fc _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
    22  CoreFoundation                      0x02fda86e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    23  CoreFoundation                      0x02fda7b0 __CFRunLoopDoObservers + 400
    24  CoreFoundation                      0x02fd01ea __CFRunLoopRun + 1226
    25  CoreFoundation                      0x02fcfa5b CFRunLoopRunSpecific + 443
    26  CoreFoundation                      0x02fcf88b CFRunLoopRunInMode + 123
    27  GraphicsServices                    0x055262c9 GSEventRunModal + 192
    28  GraphicsServices                    0x05526106 GSEventRun + 104
    29  UIKit                               0x00d86106 UIApplicationMain + 1526
    30  CatalogApp                    0x0007e36a main + 138
    31  libdyld.dylib                       0x05b61ac9 start + 1
    32  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

0 个答案:

没有答案