iOS 里面如何使用第三方应用程序打开自己的文件,调用wps其他应用打开当前应用里面的的ppt doc xls

 我们的自己的应用里面经常涉及的要打开ppt doc,这样的功能,以前总以为iOS沙盒封闭化,不可能实现,后来终于解决了

使用

UIDocumentInteractionController 来解决这一问题

使用下面代码,就可以打开airdrop ,然后你选择wps , 打开文档,OK 

- (IBAction)download:(id)sender {

   

    NSString* path = [[NSBundlemainBundle] pathForResource:@"aa"ofType:@"docx"];

    NSURL *file_URL = [NSURL fileURLWithPath:path];

    

    NSFileManager* fileManager = [NSFileManagerdefaultManager];

    if ([fileManager fileExistsAtPath:path]) {

        if (self.fileInteractionController == nil) {

            fileInteractionController = [[UIDocumentInteractionControlleralloc] init];

            

            fileInteractionController = [UIDocumentInteractionControllerinteractionControllerWithURL:file_URL];

            fileInteractionController.delegate = self;

            //[fileInteractionController retain];

            

        }else {

            self.fileInteractionController.URL = file_URL;

        }

        

        [self.fileInteractionControllerpresentPreviewAnimated:YES];

        

    }

    

}

原文地址:https://www.cnblogs.com/ccguo/p/3461134.html