【问题标题】:How to associate CSV file to my app in iOS 7如何在 iOS 7 中将 CSV 文件关联到我的应用程序
【发布时间】:2014-04-09 15:19:53
【问题描述】:

大家好。

我逐行遵循这两个教程,尝试将我的应用程序关联到 csv 文件(电子邮件应用程序附件),但是在我将这些更改添加到我的应用程序的 plist 文件之后,然后构建我的应用程序并运行它设备(iPhone 4,iOS 7.0.4),没有任何反应,我的意思是当我点击电子邮件中的 .csv 文件时,我的应用程序仍然没有出现在打开的可用应用程序列表中,我只是不知道我在哪里做错了,或者 iOS 7 有不同的方法?

http://blog.spritebandits.com/2011/12/14/importing-csv-data-file-into-an-ios-app-via-email-attachment/

http://www.raywenderlich.com/1980/email-tutorial-for-ios-how-to-import-and-export-app-data-via-email-in-your-ios-app

这就是我的 plist 更改(教程后添加的新条目)如下所示:

这是应用设置屏幕:

这是 xml 版本:

        <key>CFBundleDocumentTypes</key>
        <array>
            <dict>
                <key>CFBundleTypeName</key>
                <string>CSV Document</string>
                <key>LSHandlerRank</key>
                <string>Owner</string>
                <key>CFBundleTypeRole</key>
                <string>Viewer</string>
                <key>LSItemContentTypes</key>
                <array>
                    <string></string>
                </array>
            </dict>
        </array>
        <key>UTExportedTypeDeclarations</key>
        <array>
            <dict>
                <key>UTTypeDescription</key>
                <string>CSV Document</string>
                <key>UTTypeConformsTo</key>
                <array>
                    <string>public.data</string>
                </array>
                <key>UTTypeIdentifier</key>
                <string>Damian-s.${PRODUCT_NAME:rfc1034identifier}</string>
                <key>UTTypeTagSpecification</key>
                <dict>
                    <key>public.filename-extension</key>
                    <string>csv</string>
                    <key>public.mime-type</key>
                    <string>application/inventorytodo</string>
                </dict>
            </dict>
        </array>

【问题讨论】:

  • 你指的是什么教程?
  • 对不起 68cherries,我错过了,我刚刚将它们添加到问题中

标签: ios csv plist


【解决方案1】:

您的 CFBundleDocumentTypes 定义中缺少 UTI 类型:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>CSV Document</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string></string>
        </array>
    </dict>
</array>

应该是:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeName</key>
        <string>CSV Document</string>
        <key>LSHandlerRank</key>
        <string>Owner</string>
        <key>CFBundleTypeRole</key>
        <string>Viewer</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>Damian-s.${PRODUCT_NAME:rfc1034identifier}</string>
        </array>
    </dict>
</array>

【讨论】:

  • NSGod!天哪,你摇滚!
  • 我在 iOS 12 上试过这个并且工作正常。但不适用于 iOS 13。该应用程序未出现在点击“通过...共享文件”时显示的列表中。我错过了什么吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-11
  • 2014-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多