在Safari浏览器中打开本地PDF文件

时间:2012-03-03 13:19:29

标签: iphone objective-c ios

我的应用程序包中有一个PDF文件,我想在Safari中打开。有没有可能这样做?

提前致谢。

2 个答案:

答案 0 :(得分:2)

我认为沙盒化本身就很困难。一种解决方案是将PDF上载到服务器,然后打开该URL。否则我怀疑它会起作用。

答案 1 :(得分:2)

在外部应用程序中打开文档是可行的。查看UIDocumentInteractionController课程,这很简单:

// you'll need to keep it around
@property (nonatomic, strong) UIDocumentInteractionController *docController;

(...)

NSURL *fileUrl = // URL to your pdf file
self.docController = [UIDocumentInteractionController interactionControllerWithURL:url];
self.docController.delegate = self;
[self.docController presentOpenInMenuFromRect:CGRectZero
                                       inView:self.view animated:YES];

也就是说,pdf将提供在iBooks中打开,因为Safari显然没有吹嘘pdf阅读能力:)所以如果你坚持让Safari打开你的pdf,那可能会很棘手。

相关问题