需要在真機上調(diào)試路狮,例子中打開的是 ?doc文件,如果手機上裝了WPS或者office套件,就能調(diào)用這些應用打開绰筛。
2.第三方APP調(diào)用自己的APP,打開文件
在info.plist中添加如下代碼
NSString *str = [NSString stringWithContentsOfFile:self.filePath encoding:NSUTF8StringEncoding error:nil];
? ? ?NSURL * ?fielPp = [NSURL fileURLWithPath:str];
? ? ? ? self.documentVC = [UIDocumentInteractionController interactionControllerWithURL:_fielPp];
? ? ? ? [self.documentVC setDelegate:self];
? ? ? ? BOOL canOpen =? [self.documentVC presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];
? ? ? ?// 返回NO說明沒有可以打開該文件的愛屁屁, 友情提示一下
? ? ? ? if (canOpen == NO) {
? ? ? ? ? ? [MBProgressHUD autoShowAndHideWithMessage:@"沒有可打開的軟件"];
? ? }