Подтвердить что ты не робот

Как инициализировать UIDocumentPickerViewController со всеми типами ИМП

Я хочу открыть UIDocumentPickerViewController, и он должен позволить пользователю выбирать все типы файлов. Я попытался упомянуть все UTI в методе инициализации UIDocumentPickerViewController, но еще не смог найти допустимые UTI для некоторых файлов, таких как rar, файлы Visio, mpp, mpt

UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:[MingleUtils allowedUTIs] inMode:UIDocumentPickerModeImport];

и

+(NSArray*)allowedUTIs{
    return @[@"public.data",@"public.content",@"public.audiovisual-content",@"public.movie",@"public.audiovisual-content",@"public.video",@"public.audio",@"public.text",@"public.data",@"public.zip-archive",@"com.pkware.zip-archive",@"public.composite-content",@"public.text"];
}
4b9b3361

Ответ 1

Если вы хотите разрешить любой тип файла, вы должны использовать

UIDocumentPickerViewController* documentPicker = 
  [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.data"]
                                                         inMode:UIDocumentPickerModeImport];

См. apple docs for Концепции UTI

Ответ 2

UIDocumentPickerViewController* documentPicker = 
  [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.item"]
                                                         inMode:UIDocumentPickerModeImport];

Ответ 3

Я думаю, что ваш лучший снимок - использовать абстрактные типы UTI.

Использование kUTTypeContent и kUTTypeItem должно охватывать большинство типов файлов.

Ответ 4

Swift 5:

import MobileCoreServices

    let importMenu = UIDocumentPickerViewController(documentTypes: ["public.item"], in: .import)
    importMenu.delegate = self
    importMenu.modalPresentationStyle = .fullScreen
    self.present(importMenu, animated: true, completion: nil)