实现如下图所示:
在你的.h文件中添加 UIDocumentInteractionControllerDelegate
然后在.m文件中,新建一个方法,用来响应你点击按钮弹出时弹出popView,其中会罗列可打开当前文件的其他应用
我的方法如下
-(void)openDocumentIn{
documentController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:unEncodingURL]];
documentController.delegate = self;
documentController.UTI = @"com.microsoft.word.doc";
[documentController presentOpenInMenuFromRect:CGRectMake(760, 20, 100, 100) inView:self.view animated:YES];
}
其中
《1》 documentController.UTI 表示那些类型的文件支持第三方软件打开,此链接里面有各种类型文件对应的参数https://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
可用根据unEncodingURl中的文件后缀名去动态设置这个值
《2》rect 根据自己的需求写
本文介绍如何在iOS应用中利用UIDocumentInteractionController实现点击按钮后弹出选择器,让用户用其他支持的第三方应用打开特定类型的文件。通过设置documentController.UTI为文件对应的UTI参数,并调整弹出位置,可以实现灵活的文件打开功能。
2762

被折叠的 条评论
为什么被折叠?



