iOS Share GIFs to Messenger using UIActivityViewController

只愿长相守 提交于 2019-12-02 01:29:09

问题


I am trying to share different type of images using UIActivityViewController to facebook messenger. I am facing no problem while sharing the images (.png), but I am not able to send gif images (.gif), it is giving error "Couldn't load content".

I am converting the image to data & then sending the data in array through UIActivityViewController.

Here, I am firing a notification with the details & extracting the gif path & then processing it.

NSDictionary *dictAsset = [notification userInfo];

NSData *imageData = [NSData dataWithContentsOfFile:dictAsset[@"path"]];

NSArray *imageToShare = [NSArray arrayWithObjects: imageData, [dictAsset objectForKey:@"assetName"], nil];

NSArray *arrAsset = imageToShare;

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:arrAsset applicationActivities:nil];

Has anyone faced same issue? or if anyone has a solution then please help me out.


回答1:


iOS does not consider a GIF an image. You have to instead share it as a file:

NSURL *gifFile = [NSURL fileURLWithPath:@"funnyface.gif"];

NSArray *items = @[gifFile];

[[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];


来源:https://stackoverflow.com/questions/32546455/ios-share-gifs-to-messenger-using-uiactivityviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!