Share Gif image on facebook in ios

╄→гoц情女王★ 提交于 2020-01-06 03:47:06

问题


how to share .gif image in Facebook from my ios app? i have tried png and jpg format it works . but when i share .gif file. it will just share as normal image not as an animated image.
so if anybody had try it. please help me out to find solutions.


回答1:


Source: Guide to Animated Gifs for Facebook

If you try to upload a GIF to Facebook, a still image of the first frame will appear. However, there are three ways to try and outsmart the system.

  • Make a Youtube video look like a GIF.

  • Use a third party app on Facebook like Animated Picture. For this app, you do not use your own files. There are hundreds sorted out in different categories to choose from.

  • Post a link to the GIF. Yes, the still image will show up, but a description will accompany it. Yes, it may take more time, but
    your friends will be curious as to what it entails.

But, if the GIF you want to upload is not a moving picture, it should work just fine. If you have a GIF image that is a nonmoving image, you should have no problem uploading it to Facebook. According to the Facebook Developers page, GIFs are one of many file types allowed for uploading to the platform. Other supported image file types include JPG, PNG, PSD, TIFF, JP2, IFF, WBMP and XBM images.

PS: This was the first result that I got when I googled about it. You'll find plenty of other sources for doing the same. For example: You Can Finally Put GIFs on Facebook.




回答2:


 if ([[UIApplication sharedApplication] canOpenURL: [NSURL  URLWithString:@"facebook://app"]]){

    NSLog(@"imag %@",_GIFURL);

    self.documentationInteractionController.delegate = self;
    self.documentationInteractionController.UTI = @"com.facebook.photo";
    self.documentationInteractionController = [self setupControllerWithURL:_GIFURL usingDelegate:self];
    [self.documentationInteractionController presentOpenInMenuFromRect:CGRectZero inView:self.view animated:YES];

}
else {
    UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"facebook not installed." message:@"Your device has no facebook installed." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
}



回答3:


Use UIActivityItemProvider and extend - (id)item {} for Facebook:

Just upload the GIF to Giphy, then provide the Giphy URL to UIActivityViewController instead of the file contents, Facebook will recognize it and show the animated GIF

- (id)item
{    
    if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {
        // Upload to Giphy
        ...
        return [NSURL URLWithString:giphyURL];
    }
}

full code is in my GitHub, I am actually a iOS newb so some experts please correct me and the code if possible



来源:https://stackoverflow.com/questions/20749933/share-gif-image-on-facebook-in-ios

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