0
我有一个使用SDWebImage显示一些远程内容的iMessage应用程序。图像被下载并缓存在磁盘上。选择图像后,我想将它作为普通的UIImage(不是MSMessage)附加到消息中。通过SDWebImage下载UIImage的MSConversation.insertAttachment
下面是我使用
// image is already downloaded
let cache = SDImageCache.shared()
let key = remoteImageUrl
let fileUrlString = cache.defaultCachePath(forKey: key)!
let fileUrl = URL(string: fileUrlString)!
// image holds the correct UIImage
let image = UIImage(contentsOfFile: fileUrlString)
activeConversation?.insertAttachment(fileUrl, withAlternateFilename: "a funny gif", completionHandler: { (error) in
// error is nil here
print("error: \(error)")
})
这里代码的消息是什么样子
这似乎是消息框架无法找到该路径下的图像。
注:点击发送后,我的iMessage应用程序崩溃“MobileSMS意外退出”。
最明显的问题是,你有没有证实没有实际上是在那个URL的形象? –
是的,如果我使用UIImage(contentsOfFile:fileUrlString),正确的图像在那里 – adamF