iOS Share GIF (animated image) not Working
So far base on days research found out that :
TWITTER : For share a GIF on twitter had to use twitter API and create a multipart request to achieve the goal and its working very well.
FACEBOOK : I did share some GIF on Facebook using FACEBOOKSHAREKIT , but i don't know why sometimes Gifs are animated, sometimes not.
INSTAGRAM : To share gif on Instagram had to convert GIFS to MP4 (or any other video formats accepted by Instagram) then save it into camera roll then share it , It is little twisted but its working very well.
WHATSAPP : It not supporting GIF at all. READ THE UPDATE
To do all of this i couldn't use "UIActivityViewController" , so decided to create a custom share page. if anybody know something to add here , to help me and others please tell me (especially about Facebook).
Thanks in advance
UPDATE
WHATSAPP : Thanks to @AmmarShahid, as he mentioned in comments, Whatsapp now supports gif.
How to load GIF image in Swift?
Load GIF image Swift :
## Reference.
#1 : Copy the swift file from This Link
:
#2 : Load GIF image Using Name
let jeremyGif = UIImage.gifImageWithName("funny")
let imageView = UIImageView(image: jeremyGif)
imageView.frame = CGRect(x: 20.0, y: 50.0, width: self.view.frame.size.width - 40, height: 150.0)
view.addSubview(imageView)
#3 : Load GIF image Using Data
let imageData = try? Data(contentsOf: Bundle.main.url(forResource: "play", withExtension: "gif")!)
let advTimeGif = UIImage.gifImageWithData(imageData!)
let imageView2 = UIImageView(image: advTimeGif)
imageView2.frame = CGRect(x: 20.0, y: 220.0, width:
self.view.frame.size.width - 40, height: 150.0)
view.addSubview(imageView2)
#4 : Load GIF image Using URL
let gifURL : String = "http://www.gifbin.com/bin/4802swswsw04.gif"
let imageURL = UIImage.gifImageWithURL(gifURL)
let imageView3 = UIImageView(image: imageURL)
imageView3.frame = CGRect(x: 20.0, y: 390.0, width: self.view.frame.size.width - 40, height: 150.0)
view.addSubview(imageView3)
Download Demo Code
OUTPUT :
iPhone 8 / iOS 11 / xCode 9
How to display GIF in app?
As @Patrick suggested, you have to replace your image path from asset folder and move it in your app’s bundle. This issue is also raised in its official git library’s issue tab. https://github.com/bahlo/SwiftGif/issues/67.
Related Topics
Uitableviewcellaccessorycheckmark and Autolayout Constraints
Thread 1:Exc_Bad_Access (Code = 1, Address = 0X30000008)
How to Properly Remove Node When Out of Screen Bounds
Enable Uialertaction of Uialertcontroller Only After Input Is Validated
iOS 7 When Rotating View in Tab Bar, Right Side of View Is Not Clickable
Static VS Class as Class Variable/Method (Swift)
Generate Rsa Public Key from Modulus and Exponent
Gamecenter iOS 9 Gamecenter Gklocalplayerlistener Methods Not Called
How to Call Https Url in Uiwebview
How to Change Tint Color of Uialertcontroller
Nsdata to Nsstring with JSON Response
This Code Signature Is No Longer Supported When Building App on iPhone 12
Changes to Swiftui Fetchrequest Not Triggering View Refresh