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
總結
以上是生活随笔為你收集整理的iOS 里面如何使用第三方应用程序打开自己的文件,调用wps其他应用打开当前应用里面的的ppt doc xls...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GoF的23个经典设计模式
- 下一篇: jquery div拖动效果示例代码