【问题标题】:IOS 13 - File Attached is not working when sharing from Mail AppIOS 13 - 从邮件应用程序共享时附加的文件不起作用
【发布时间】:2020-06-01 09:38:36
【问题描述】:

从来没有分享过扩展。

从带有共享扩展的邮件应用程序共享附件无法正常工作。但从 Gmail 应用程序共享附件(pdf、doc、图像等)工作正常。

NSExtensionActivationRule

<key>NSExtensionActivationRule</key>
            <dict>
                <key>NSExtensionActivationSupportsFileWithMaxCount</key>
                <integer>1</integer>
                <key>NSExtensionActivationSupportsImageWithMaxCount</key>
                <integer>1</integer>
                <key>NSExtensionActivationSupportsAttachmentsWithMaxCount</key>
                <integer>1</integer>
            </dict>

代码:-

for attachment in contents{
            if attachment.hasItemConformingToTypeIdentifier(kUTTypeImage as String) {
                attachment.loadItem(forTypeIdentifier: kUTTypeImage as String, options: nil) { data, error in
                    //Do action for image
                }
            } else  {
                if let item = (filePicker!.types as [String]).first(where: { (item) -> Bool in attachment.hasItemConformingToTypeIdentifier(item)}){

                    attachment.loadItem(forTypeIdentifier: item, options: nil) { data, error in
                        //Do action for file
                    }
                }
            }
        }

【问题讨论】:

    标签: ios swift ios13 ios-extensions ios-sharesheet


    【解决方案1】:
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-20
    • 2014-07-11
    相关资源
    最近更新 更多