【发布时间】:2023-03-14 12:16:02
【问题描述】:
我的应用程序按钮中有通过 whatsapp 共享图像的按钮,它确实有效。但是在某些设备上的 UIDocumentInteractionController 的菜单中出现了一些奇怪的东西。 这是代码:
let urlWhats = "whatsapp://app"
if let urlString = urlWhats.addingPercentEncoding(withAllowedCharacters:CharacterSet.urlQueryAllowed) {
if let whatsappURL = URL(string: urlString) {
if UIApplication.shared.canOpenURL(whatsappURL as URL) {
if let imageData = UIImageJPEGRepresentation(self.ivFramedPicture.image!, 1.0) {
let tempFile = URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent("/Documents/whatsAppTmp.wai")
do {
try imageData.write(to: tempFile, options: .atomic)
self.documentInteractionController = UIDocumentInteractionController(url: tempFile)
self.documentInteractionController.delegate = self
self.documentInteractionController.uti = "net.whatsapp.image"
self.documentInteractionController.presentOpenInMenu(from: CGRect.zero, in: self.view, animated: true)
} catch {
print(error)
}
}
} else {
// Cannot open whatsapp
}
}
}
如果我点击 1 whatsapp 图标,它会发送一些在 iPhone 上无法打开的文件(Android 会像图像一样打开该文件)
有没有人可以帮助解决这个问题?我只想要一个带有共享图像的图标,就是这样。谢谢
【问题讨论】: