如何在 UIDocumentMenuViewController iOS 中只允许 doc 和 pdf 类型?

How to allow only doc and pdf type in UIDocumentMenuViewController iOS?

我尝试使用 UIDocumentMenuViewController 从 Dropbox/G-Drive/iCloud 加载一些文件。我试过了,

UIDocumentMenuViewController *importMenu = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:@[(__bridge NSString*)kUTTypeContent] inMode:UIDocumentPickerModeImport];
importMenu.delegate = self;
importMenu.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:importMenu animated:YES completion:nil];

用这个来完成这个。但是我只需要从选择器中获取 docpdf 类型。但是当我使用 kUTTypeContent 时,这也允许图像和视频。有没有办法只允许此选择器用于 doc 和 pdf(自定义类型),或者为什么要阻止媒体文件?请帮我解决这个问题。

我从 apple developer site 找到了解决方案。有一种名为 kUTTypeCompositeContent 的类型,它仅支持所有文档类型,如 doc、pdf、xls 等。

public.composite-content:(kUTTypeCompositeContent)

Base type for mixed content. For example, a PDF file contains both text and special formatting data.