使用iOs上的默认应用程序打开文件

问题描述:

我正在尝试在iPad上下载一个文件(存储到应用程序文档目录中)openWithDefaultApplication。我安装了PDFReaderLite,仍然openWithDefaultApplication不重新识别扩展名pdf。我能做些什么来使PDFReaderLite成为打开pdf的默认应用程序?使用iOs上的默认应用程序打开文件

预先感谢您

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/File.html#openWithDefaultApplication%28%29这表明openWithDefaultApplication是桌面功能。我不认为默认应用程序的功能甚至存在于iOS ...

+0

是的,我读过。没有提示该功能在移动设备上不起作用。有关如何以另一种方式打开文件的想法? – Eugeny89 2012-04-05 11:08:26

+0

只有一种方法可以在iOS上执行此操作。您必须使用应用程序旨在打开的自定义URL并使用它调用应用程序。但是,您无法将此功能添加到现有的应用程序。它必须由作者添加。此链接有更多信息:http://iphonedevelopertips.com/cocoa/launching-your-own-application-via-a-custom-url-scheme.html – borrrden 2012-04-05 11:51:52

UIButton *button = (UIButton *)sender; 
    NSURL *URL = [[NSBundle mainBundle] URLForResource:@"file_1" withExtension:@"pdf"]; 


    if (URL) { 
     // Initialize Document Interaction Controller 
     self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL]; 

     // Configure Document Interaction Controller 
     [self.documentInteractionController setDelegate:self]; 

     // Present Open In Menu 
     BOOL flag =[self.documentInteractionController presentOpenInMenuFromRect:[button frame] inView:self.view animated:YES]; 

     if (!flag) { 

      //[appDel showAlert:@"There is no supported app installed in your phone"]; 
      [self.documentInteractionController presentPreviewAnimated:YES]; 
     }