【发布时间】:2017-06-26 18:40:11
【问题描述】:
我正在尝试在我的应用程序中从 iCloud 驱动器打开 .obj 文件,抛出 UIDocumentPickerViewController。我找不到 .obj 文件的标准 UTi。所以,使用这个https://developer.apple.com/library/content/qa/qa1587/_index.html,我尝试为我的应用添加对这个文件扩展名的支持。
有 info.plist 部分:
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>arrow1</string>
</array>
<key>CFBundleTypeName</key>
<string>OBJ model</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.giena.Interface.obj</string>
</array>
</dict>
</array>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeDescription</key>
<string>OBJ model</string>
<key>UTTypeIdentifier</key>
<string>com.giena.Interface.obj</string>
<key>UTTypeSize320IconFile</key>
<string>arrow1</string>
<key>UTTypeSize64IconFile</key>
<string>arrow1</string>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>obj</string>
</array>
</dict>
</dict>
</array>
还有 UIDocumentPickerViewController 调用:
UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithDocumentTypes:@[@"public.text"] inMode:UIDocumentPickerModeOpen];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];
当我运行应用程序时,我看到用于文件选择的弹出视图,但 .obj 文件是灰色的且不可选择。我做错了什么?
【问题讨论】:
-
它看起来像一个错误......今天我尝试使用虚拟文件扩展名 .tst 和 .xxxx 执行此操作,并且它工作正常。但是使用 .obj 扩展名我遇到了问题。
-
您正在尝试选择 .obj 文件,但您在文档类型中提到了“public.text”。如果你解决了这个问题,你能告诉我自定义扩展的确切含义吗?
标签: ios info.plist uti