【问题标题】:Share Gif image on facebook in ios在 ios 的 facebook 上分享 Gif 图像
【发布时间】:2014-01-12 01:11:06
【问题描述】:
如何通过我的 ios 应用在 Facebook 中分享 .gif 图像?
我试过 png 和 jpg 格式,它可以工作。
但是当我分享 .gif 文件时。
它只会作为普通图片分享而不是作为动画图片分享。
所以如果有人尝试过。请帮助我找到解决方案。
【问题讨论】:
标签:
facebook
facebook-graph-api
ios5
ios7
【解决方案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】:
使用 UIActivityItemProvider 并为 Facebook 扩展 - (id)item {}:
只需将 GIF 上传到 Giphy,然后将 Giphy URL 提供给 UIActivityViewController 而不是文件内容,Facebook 将识别它并显示动画 GIF
- (id)item
{
if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {
// Upload to Giphy
...
return [NSURL URLWithString:giphyURL];
}
}
完整的代码在我的GitHub,我实际上是一个iOS新手,所以请一些专家纠正我和代码如果可能的话