|
1
2
3
4
|
documentController = [
UIDocumentInteractionController
interactionControllerWithURL:[
NSURL
fileURLWithPath:filePath]];
documentController.delegate =
self
;
documentController.UTI = @
"com.microsoft.word.doc"
;
[documentController presentOpenInMenuFromRect:CGRectMake(760, 20, 100, 100) inView:
self
.view animated:
YES
];
|
其中filePath为你要打开的文件路径,
UTI可以去
https://developer.apple.com/library/mac/#documentation/Miscellaneous/Reference/UTIRef/Articles/System-DeclaredUniformTypeIdentifiers.html
根据filePath文件后缀名去动态设置
本文提供了一个使用Objective-C实现的iOS应用中文件分享功能的代码示例。具体包括通过UIDocumentInteractionController来展示文件并允许用户选择不同的应用进行打开操作。代码详细展示了如何设置文档控制器、指定文件路径及统一类型标识符(UTI),并调用方法显示文件菜单。

9821

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



