UIDocumentInteractionController自iOS6以来无法工作
问题描述:
在我的应用程序中,我使用UIDocumentInteractionController将PDF文档打开到acrobat reader(或任何其他查看器),但自iOS6以后它不再工作。UIDocumentInteractionController自iOS6以来无法工作
我已经尝试了很多的东西,最后是从here:
UIDocumentInteractionController *docController = [[UIDocumentInteractionController alloc]init];
docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:documentsDirectory]];
docControler.UTI = @"com.adobe.pdf";
docController.delegate = self;
CGrect navRect = self.view.frame;
[docController presentOpenInMenuFromRect:navRect inView:self.view animated:YES];
当此代码运行时,我的应用程序完全冻结。 我试着用“presentOpenInMenuFromBarButtonItem”但我有同样的问题。
答
控制器分配给强引用属性:
@property (nonatomic, strong) UIDocumentInteractionController *docController;
答
我用UIDocumentInteractionController成功的iOS 6的代码示例:
self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:myPDFPath]];
[self.documentInteractionController presentOpenInMenuFromBarButtonItem:self.actionButton animated:YES];
您需要保留到UIDocumentInteractionController或参考它会在工作完成之前发布。
此外,它看起来像使用文档文件夹的路径,而不是特定文件的路径。我认为这不会起作用 - 将路径传递给特定的文件。
+0
我使用我的PDF文档的路径,它只是一个错误的命名变量。你的回答不起作用,但它会在我的日志控制台中添加以下内容:[ViewControllerApps setDocController:]无法识别的选择器发送到实例0x763000 – 2013-04-08 14:36:24
不幸的是它不起作用。这似乎是一个弹出窗口打开,并立即在我的iPhone的左上角,以阻止我的应用程序......怪异 – 2013-04-08 14:33:31
而不是指定矩形,尝试通过'CGRectZero'。 – daltonclaybrook 2013-04-08 14:39:25
同样的问题,但我已经绕过这个问题,打开我的pdf到一个UIWebView。感谢您的帮助 – 2013-04-08 15:03:19