【发布时间】: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