无法从iOS Word应用程序将MS Word文档复制到我的应用程序

3

我想在我的应用程序代理函数中打开一个Word文件,使用如下代码:

- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options

通过添加到我的Info.plist文件中

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>doc</string>
        </array>
        <key>CFBundleTypeIconFile</key>
        <string>AppIcon.icns</string>
        <key>CFBundleTypeName</key>
        <string>Microsoft doc</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
            <string>com.microsoft.word.doc</string>
        </array>
    </dict>
</array>

当我在Google Inbox应用程序中打开带有Word文档附件的电子邮件时,我可以在“文档交互控制器”中看到我的应用程序,并将Word文件的副本发送到委托函数。
但是,当我通过在最近文件列表中单击Word文件后面的“...”来打开iOS Word应用程序中的“文档交互控制器”,然后选择“共享”>“发送副本”>“使用其他应用程序发送”时,我的应用程序在“文档交互控制器”中不可见。
我应该怎么做才能在iOS Word应用程序的“文档交互控制器”中看到我的应用程序,以便在我的应用程序中编辑Word文件?
1个回答

1

看起来您需要在Info.plist中提到LSItemContentTypes符合org.openxmlformats.wordprocessingml.document格式

所以Info.plist将变成:

<key>CFBundleDocumentTypes</key>
<array>
    <dict>
        <key>CFBundleTypeExtensions</key>
        <array>
            <string>doc</string>
        </array>
        <key>CFBundleTypeIconFile</key>
        <string>AppIcon.icns</string>
        <key>CFBundleTypeName</key>
        <string>Microsoft Word</string>
        <key>CFBundleTypeRole</key>
        <string>Editor</string>
        <key>LSHandlerRank</key>
        <string>Alternate</string>
        <key>LSItemContentTypes</key>
        <array>
          <string>com.microsoft.word.doc</string>
          <string>org.openxmlformats.wordprocessingml.document</string>
        </array>
    </dict>
</array>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接