2013-04-08 52 views
0

在我的應用程序中,我使用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」但我有同樣的問題。

回答

4

控制器分配給強引用屬性:

@property (nonatomic, strong) UIDocumentInteractionController *docController; 
+0

不幸的是它不起作用。這似乎是一個彈出窗口打開,並立即在我的iPhone的左上角,以阻止我的應用程序......怪異 – 2013-04-08 14:33:31

+0

而不是指定矩形,嘗試通過'CGRectZero'。 – daltonclaybrook 2013-04-08 14:39:25

+0

同樣的問題,但我已經繞過這個問題,打開我的pdf到一個UIWebView。感謝您的幫助 – 2013-04-08 15:03:19

1

我用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