无法将数组PDF发送到QuickLook预览

时间:2014-01-22 21:27:50

标签: ios quicklook qlpreviewcontroller

我正在尝试一些应该简单的事情,但我认为我错过了一些明显的东西。

我只是想将一系列PDF加载到QuickLook预览中。文件名列在plist文件中,所以首先我加载plist的内容并循环遍历它,生成一个文件名数组。然后我想将该数组传递给QuickLook预览并将预览发送到导航控制器。

这首先将文件列表传递给tableview,然后当你点击表格单元格时,它会在你点击的单元格的索引处打开预览。

我的目标是消除tableview,只需在零索引处加载预览。

我怀疑是我传递了错误的数组,或错误的文件路径(我想我试图发送一系列NSURL,但也许这是错误的事情要做。)

无论如何,应用程序构建正常并启动。但是一旦它尝试加载QuickLook预览,它就会挂起。

有人可以告诉我我在这里失踪了吗?


// issueName是plist文件的基本名称...

NSString *path = [[NSBundle mainBundle] pathForResource:issueName ofType:@"plist"];
NSArray *documentSpecs = [[NSArray alloc] initWithContentsOfFile:path];

NSString *documentName = [[NSString alloc]init];
NSURL *documentURL = [[NSURL alloc]init];

for (NSString *documentSpec in documentSpecs) {
    NSArray *components = [documentSpec componentsSeparatedByString:@";"];
    documentName = components[0];

    documentURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:documentName ofType:@"pdf"]];

    [documentURLs addObject:documentURL];
}

docURLs = [NSArray arrayWithArray:documentURLs];


QLPreviewController *preview = [[QLPreviewController alloc] init];
preview.dataSource = self;
preview.currentPreviewItemIndex = 0;

[[self navigationController] pushViewController:preview animated:YES];

顺便说一句,我确实添加了一个QuickLook数据源,或者至少我认为我做过了,但也许我搞砸了这个:


 #pragma mark - QuickLook Preview Data Source

 - (NSInteger) numberOfPreviewItemsInPreviewController: (QLPreviewController *) controller
 {
      return [self.docURLs count];
 }

 - (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
 {
     return self.docURLs[index];
 }

有人可以帮我解决这个问题吗?谢谢!

0 个答案:

没有答案
相关问题