无法使用UIDocumentPickerViewController选择页面文件 [英] Unable to pick pages file with UIDocumentPickerViewController
问题描述
我正在使用UIDocumentPickerViewController来选择文档.以下是指定的UTI:
I'm using UIDocumentPickerViewController for picking document. Below are the specified UTIs :
NSArray *types = @[(NSString*)kUTTypeImage,(NSString*)kUTTypeSpreadsheet,(NSString*)kUTTypePresentation,(NSString*)kUTTypePDF,(NSString*)kUTTypeRTF,(NSString*)kUTTypePlainText,(NSString*)kUTTypeText];
UIDocumentPickerViewController *dpvc = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:types inMode:UIDocumentPickerModeImport];
从页面应用程序创建的文件(页面文件)显示为灰色,无法选择.但是WhatsApp文档选择器允许选择相同的文件.我是否缺少任何必需的UTI?
The files created from pages app (pages file) are grayed out and unable to pick. But WhatsApp document picker allowed to pick the same files. Am I missing any required UTI ?
我的应用程序:
WhatsApp:
更新
com.apple.iwork.pages.sffpages可以解决我设备上的页面文件,但不适用于icloud驱动器上的文件.呈现文档选择器的完整代码为:
com.apple.iwork.pages.sffpages did the trick for pages files on my device, but not working for the files on icloud drive. The complete code to present document picker is:
-(IBAction)showDocumentPicker:(id)sender
{
NSArray *types = @[(NSString*)kUTTypeImage,(NSString*)kUTTypeSpreadsheet,(NSString*)kUTTypePresentation,(NSString*)kUTTypePDF,(NSString*)kUTTypeRTF,(NSString*)kUTTypePlainText,(NSString*)kUTTypeText, @"com.apple.iwork.pages.sffpages"];
UIDocumentPickerViewController *dpvc = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:types inMode:UIDocumentPickerModeImport];
dpvc.delegate = self;
//colorFromHex 4285f4
[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:66.0/255.0 green:133.0/255.0 blue:244.0/255.0 alpha:1.0]];
[self presentViewController:dpvc animated:YES completion:nil];
}
推荐答案
实际上,Pages文件有2种不同类型,可以是捆绑包或单个文件,我认为您希望应用程序同时处理这两种文件.
Actually, there are 2 different types for Pages files, it could be a bundle or a single file, and I think that you want your app to handle both.
对应的UTI是com.apple.iwork.pages.sffpages
和com.apple.iwork.pages.pages
.
导入iWork文件的代码示例:
Example of code to import iWork files:
NSArray *types = @[@"com.apple.iwork.pages.sffpages", @"com.apple.iwork.pages.pages", @"com.apple.iwork.numbers.numbers", @"com.apple.iwork.keynote.key"];
UIDocumentPickerViewController *dpvc = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:types inMode:UIDocumentPickerModeImport];
如果您在使用UIDocumentPickerViewController
时仍然遇到问题,我还建议您观看此WWDC会话: https://developer.apple.com/videos/play/wwdc2018/216
I also recommand that you watch this WWDC session if you still have trouble with UIDocumentPickerViewController
: https://developer.apple.com/videos/play/wwdc2018/216
这篇关于无法使用UIDocumentPickerViewController选择页面文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!