【发布时间】:2012-03-13 08:37:29
【问题描述】:
如何使用自己的应用程序打开存储在 iPad/iPhone 中的 PDF 文件?
【问题讨论】:
-
提问前你搜索了吗??
-
“如何打开 PDF 文件...”与“打开 word 和 excel 文件”几乎没有重复 :-)
标签: ios objective-c pdf
如何使用自己的应用程序打开存储在 iPad/iPhone 中的 PDF 文件?
【问题讨论】:
标签: ios objective-c pdf
有一个很好的教程here 演示了如何在您的应用程序中打开 .pdf、.xls 文件。
您必须参考的主要课程是QLPreviewController。 here
这是您必须调用的数据源方法
- (id <QLPreviewItem>)previewController: (QLPreviewController *)controller previewItemAtIndex:(NSInteger)index
{
// Break the path into it's components (filename and extension)
NSArray *fileComponents = [[arrayOfDocuments objectAtIndex: index] componentsSeparatedByString:@"."];
// Use the filename (index 0) and the extension (index 1) to get path
NSString *path = [[NSBundle mainBundle] pathForResource:[fileComponents objectAtIndex:0] ofType:[fileComponents objectAtIndex:1]];
return [NSURL fileURLWithPath:path];
}
还有人想参考这个 SO 问题:iPhone - Opening word and excel file without using UIWebview。
【讨论】:
您可以使用 Core Graphics 来完成此任务。 查看苹果资源中的PDFView 示例
【讨论】: