[iOS]UIDocumentPickerViewController支援docx, pptx, xlsx格式

依據Apple Document說明,Microsoft文件的UTI如下
doc com.microsoft.word.doc
ppt com.microsoft.powerpoint.ppt
xls com.microsoft.excel.xls

但沒有提到docx, pptx, xlsx格式,後來翻到一篇實用的文章有列出此三款UTI如下
docx org.openxmlformats.wordprocessingml.document
pptx org.openxmlformats.presentationml.presentation
xlsx   org.openxmlformats.spreadsheetml.sheet

經實際測試,不需要設置info.plist,直接使用UTI即可
sample code如下:
NSArray *documentTypes = @[@"com.microsoft.word.doc", @"org.openxmlformats.wordprocessingml.document", @"com.microsoft.excel.xls", @"org.openxmlformats.spreadsheetml.sheet", @"com.microsoft.powerpoint.ppt", @"org.openxmlformats.presentationml.presentation"];
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:documentTypes inMode:UIDocumentPickerModeOpen];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:documentPicker animated:YES completion:nil];

沒有留言: