我正在将UIDocumentInteractionController放入我的应用程序中,该程序可以从服务器下载任意文件类型。
它的存在有两个目的:
我想要这样做的是仅尝试显示系统能够预览的文件类型的预览。例如,如果它是一个zip文件,则系统无法预览该文件,因此我想直接转到“打开位置”。
我在任何地方都找不到支持预览的类型的列表。
这是我的代码:
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;
}
}
最佳答案
方法presentPreviewAnimated:
返回一个BOOL值(如果可以预览,则返回YES,如果不进行管理,则返回NO),因此您可以:
if (![self.docController presentPreviewAnimated:YES])
{
//present openIn
}
关于ios - UIDocumentInteractionController可以预览哪些文件类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20948102/