Ste*_*rck 3 gif ios uiactivityviewcontroller swift
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)
Run Code Online (Sandbox Code Playgroud)
The URLString contains a .gif link. Would anyone know how to share the Gif image?
我已经找到答案了。您不必共享实际图像。要共享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)
Run Code Online (Sandbox Code Playgroud)
编码愉快!
| 归档时间: |
|
| 查看次数: |
1823 次 |
| 最近记录: |