【问题标题】:InsertAttachment withAlternateFilename is not working in iOS 10带有备用文件名的插入附件在 iOS 10 中不起作用
【发布时间】:2017-01-10 15:06:49
【问题描述】:

根据文档:

@method     insertAttachment:withAlternateFilename:completionHandler:
@abstract   The NSURL instance provided in the URL parameter is inserted into the Messages.app
input field. This must be a file URL.
@param      URL                The URL to the media file to be inserted.
@param      filename           If you supply a string here, the message UI uses it for the attachment. Use an alternate filename to better describe the attachment or to make the name more readable.
@param      completionHandler  A completion handler called when the insert is complete.
 */
open func insertAttachment(_ URL: URL, withAlternateFilename filename: String?, completionHandler: (@escaping (Error?) -> Swift.Void)? = nil)

它说的地方

filename ---> 如果您在此处提供一个字符串,则消息 UI 将其用于 附件。使用备用文件名更好地描述 附件或使名称更具可读性。

我的代码是:

if let conversation = activeConversation {
    conversation.insertAttachment(fileURL, withAlternateFilename: "This is file Description.", completionHandler: nil)
}

但它没有显示在消息应用程序的任何地方。

我在这里发送视频文件。

如果可能,我想在用户单击消息时或在MSMessage 下方显示该描述。

【问题讨论】:

  • 在设置备用文件名时尽量指定文件的扩展名,例如:“This is file Description.png”
  • 感谢您的评论,但它没有帮助。 @azimov
  • 你有没有想过这个问题?我遇到了同样的问题!
  • 2019,仍然是一个错误。
  • 这个的 Swift 版本被破坏了。这个的objective-C版本按预期工作。必须导入 Objective-C .h 和 .m 文件并为您的 Swift 项目提供一个桥接头。效果很好,文件名正确

标签: swift swift3 ios10 imessage ios-messages-extension


【解决方案1】:

截至 WWWDC 2020,我认为这已通过 Xcode 12 或 iOS 14 修复,因为我在 Xcode 11 中看到了它,但我更新的构建工作正常。

【讨论】:

    【解决方案2】:

    【讨论】:

    • 仅供参考:这不仅是错误的类文档,而且是错误的 framework(如果你想知道为什么你得到这么多反对票,那是我的猜测)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-14
    • 1970-01-01
    • 2014-03-11
    • 2020-06-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多