分享Gifs Swift

我如何在Swift中分享Gif? 我现在用来共享Gif URL的方法只共享一个图像而不共享动画Gif图像。 这就是我现在所拥有的:

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) 

URLString包含.gif链接。 有谁知道如何分享Gif图像?

我找到了答案。 您不必共享实际图像。 要共享一个gif,你所做的就是共享数据:

  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) 

快乐的编码!