2015-10-15 78 views
2

我用UIDocumentInteractionController presentOptionsMenuFromBarButtonItem在Adobe Reader應用程序打開PDF,用郵件發送和打印。郵件和打印工作正常,但我無法打開任何其他應用程序。我試過presentOpenInMenuFromBarButtonItem和UIActivityViewController,但他們都沒有做我所需要的。UIDocumentInteractionController presentOptionsMenuFromBarButtonItem不打開應用程序

我試圖打開Adobe Reader時與documentInteractionController:willBeginSendingToApplication:委託,但我無法找到我怎麼能在PDF格式傳遞給應用程序。可能嗎?

如果沒有,是否有另一種方式在Adobe Reader應用程序打開PDF,用郵件發送和打印呢?

感謝

+0

什麼用UIActivityController是怎麼回事? – rmaddy

回答

2

通常,這是我該怎麼辦:

NSURL *documentsDirectoryPath = [NSURL fileURLWithPath:[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]]; 

    NSURL *URL =[documentsDirectoryPath URLByAppendingPathComponent:@"your pdf"]; 

    UIButton *button = (UIButton *)nil; 
    self.documentInteractionController.delegate=self; 
    if (URL) { 
     // Initialize Document Interaction Controller 
     self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL]; 
     // Configure Document Interaction Controller 
     [self.documentInteractionController setDelegate:self]; 
     //preview 
     [self.documentInteractionController presentPreviewAnimated:YES]; 
     // Present Open In Menu 
     [self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES]; 

    } 
+0

感謝您的回答,但presentOpenInMenuFromRect僅適用於其他應用程序(Adobe Reader可以毫無問題地打開)。它沒有顯示任何通過郵件發送或打印文件的選項。 – olivierplante

+0

檢查內容:HTTP://stackoverflow.com/questions/23336363/uidocumentinteractioncontroller-does-not-show-mail-option –

+0

我已經使用presentOptionsMenuFromBarButtonItem(這是我的第一選擇),但因爲一對夫婦的時候它不會打開Adobe Reader(或任何其他應用程序)。它只適用於郵件和打印。我用documentController.UTI = @「com.adobe.pdf」設置了UTI; – olivierplante

相關問題