想要通过 UIActivityController 与 WhatsApp 共享我的应用程序中的 UIImage。但当我分享它时,我会收到以下错误消息:
[u 3F6F03F6-805B-4DF3-B3C5-188EA72B9C0C:m (null)]
[net.whatsapp.WhatsApp.ShareExtension(24.15.79)] Connection to plugin interrupted while in use.
let shareButtonAction = UIAction { [weak self] _ in
if let imageSource = self!.imageView.imageSource{
let items = [imageSource as AnyObject]
let ac = UIActivityViewController(activityItems: items, applicationActivities: nil)
ac.excludedActivityTypes = [UIActivity.ActivityType.print, UIActivity.ActivityType.postToWeibo, UIActivity.ActivityType.copyToPasteboard, UIActivity.ActivityType.addToReadingList, UIActivity.ActivityType.postToVimeo]
self!.present(ac, animated: true)
}
}
我已经检查过 WhatsApp 页面,但不知道如何解决这个问题。我也找不到这个主题的帖子。仅关于如何一起共享图像和文本。 有人已经遇到这个问题并且可以帮助我吗?谢谢你
好的,我可以自己解决。看来你必须将 UIImage 转换为 JPEG 数据。我希望有一天这会对某人有所帮助
if let imageSource = self!.imgview.image{
let dataImage = imageSource.jpegData(compressionQuality: 1.0)
let items = [dataImage]
let ac = UIActivityViewController(activityItems: items as [Any], applicationActivities: nil)