swift - 带有 UTI 的 UIDocumentBrowserViewController 错误

标签 swift ios11 xcode9 uidocumentbrowservc

我使用 UIDocumentViewController(来自 Xcode 9 模板)为 iOS 11 创建了一个应用程序。 我注册了文档类型以支持 .swift 文件(public.swift-script),并且它正在使用 open in place 和 Files 应用程序,但在应用程序的浏览器中,扩展名为 .swift 的文件被禁用,我无法选择它们。

我不知道是 iOS 11 错误还是我,因为如果我将文档类型设置为与 public.item 文件一起使用,它就可以工作。

注意:如果我允许选择多个项目,也会发生同样的事情,但如果我单击“全选”,文件将被正常选择。

最佳答案

我可能没有我需要的所有信息,但使用模板和我对你的问题的理解,我需要做的就是将 UTI 添加到 Info.plist 中,如下所示:

通过来源

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeIconFiles</key>
        <array/>
        <key>CFBundleTypeName</key>
        <string>Source Code</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>public.swift-source</string>
        </array>
    </dict>
    <dict/>
</array>

Via the GUI

如果我误解了你的问题,请告诉我。

关于swift - 带有 UTI 的 UIDocumentBrowserViewController 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44599192/

相关文章:

iOS 11.0.1 在 vi​​ewDidLayoutSubviews 中崩溃

ios - tableView Swift 中的乘积值

ios - iOS 11 如何从 iOS Receipt 中获取 original_application_version(第一个购买的版本号)?

ios - 当应用程序被杀死时,Swift 向服务器发送请求

swift - 如何使用 iOS 11 和 Swift 3 在 UINavigation Bar 的 Stack View 中为 UIButtons 启用点击手势

uibarbuttonitem - BarButtonItems 和标题未出现在 iOS 11 中

ios - InputAccessoryView 不显示在 SubViewController 中

ios - UIView 在子类中作为 @IBOutlet 而在父类(super class)中是实例属性,而不是 socket

swift - Swift 1.2 中的 @noescape 属性

ios - ObserveSingleEvent 返回旧数据