Я хочу поделиться анимационным изображением WAPB с WhatsApp и другой платформой, но оно просто показывает только изображение первого кадра. Я хочу поделиться анимированными изображениями. < /P>
func shareGIF(from viewController: UIViewController, gifURLString: String) {
guard let url = URL(string: gifURLString) else {
print("Invalid URL")
return
}
// Download the WebP file
URLSession.shared.dataTask(with: url) { data, response, error in
if let error = error {
print("Download error: \(error.localizedDescription)")
return
}
guard let data = data else {
print("No data downloaded")
return
}
// Save WebP data to temporary file
let tempDirectory = FileManager.default.temporaryDirectory
let tempFileURL = tempDirectory.appendingPathComponent("tempSticker.webp")
do {
try data.write(to: tempFileURL)
DispatchQueue.main.async {
// Present the share sheet on the main thread
let activityVC = UIActivityViewController(activityItems: [tempFileURL], applicationActivities: nil)
if let popoverController = activityVC.popoverPresentationController {
popoverController.sourceView = viewController.view
popoverController.sourceRect = CGRect(x: viewController.view.bounds.midX,
y: viewController.view.bounds.midY,
width: 0, height: 0)
popoverController.permittedArrowDirections = []
}
viewController.present(activityVC, animated: true)
}
} catch {
print("Error saving WebP: \(error.localizedDescription)")
}
}.resume()
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... -ios-swift