How would I share a Gif in Swift? The method I am using right now to share the Gif URL only shares one image and does not share the animated Gif image. Here is what I have right now:
var cell = self.collectionView.cellForItemAtIndexPath(index)
println(index.item)
var URLString: String = contentArray[index.item].contentUrlStirng
var shareURL: NSURL = NSURL(string: "\(URLString)")!
var shareImage: UIImage = UIImage.animatedImageWithAnimatedGIFURL(shareURL)
let firstActivityItem: Array = [shareImage]
let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: firstActivityItem, applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)
The URLString
contains a .gif link. Would anyone know how to share the Gif image?
I have figured out the answer. You don't have to share the actual image. To share a gif all you do is share the data as such:
var cell = self.collectionView.cellForItemAtIndexPath(index)
println(index.item)
var URLString: String = contentArray[index.item].contentUrlStirng
var shareURL: NSURL = NSURL(string: "\(URLString)")!
var shareData: NSData = NSData(contentsOfURL: shareURL)!
let firstActivityItem: Array = [shareData]
let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: firstActivityItem, applicationActivities: nil)
self.presentViewController(activityViewController, animated: true, completion: nil)
Happy Coding!