我们的自己的应用里面经常涉及的要打开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];
}
}