Ben*_*ton 1 objective-c uikit ios uidocumentinteraction
我将一个UIDocumentInteractionController放入我的应用程序,它可以从服务器下载任意文件类型.
这有两个目的:
我想要的是只尝试显示系统能够预览的文件类型的预览.例如,如果它是一个zip文件,系统无法预览,所以我想直接进入'Open In'.
我无法在任何地方找到支持预览的类型列表.
这是我的代码:
self.docController = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
[self.docController setDelegate:self];
// I'd like to skip this line if the system can't preview the file.
BOOL isOpen = [self.docController presentPreviewAnimated:YES];
if (!isOpen) {
BOOL canOpen = [self.docController presentOpenInMenuFromRect:CGRectMake(300, 300, 100, 100)
inView:self.view
animated:NO];
if (!canOpen) {
// tell user to install an app that's able to open this file.
return;
}
}
Run Code Online (Sandbox Code Playgroud)
该方法presentPreviewAnimated:返回BOOL值(如果设置为预览则为YES,而不管理则为NO),因此您可以:
if (![self.docController presentPreviewAnimated:YES])
{
//present openIn
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3185 次 |
| 最近记录: |