我可以从UIActivityViewController和原生的UIActivityTypePostToTwitter发送动画GIF吗? [英] Can I tweet an animated GIF from a UIActivityViewController and the native UIActivityTypePostToTwitter yet?

查看:188
本文介绍了我可以从UIActivityViewController和原生的UIActivityTypePostToTwitter发送动画GIF吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIActivityViewController 共享一个对象


  • 符合 UIActivityItemSource 协议和

  • 通过返回 NSURL 来提供动画GIF文件.gif文件和 CFBridgingRelease(kUTTypeGIF)在适当的方法中。

  • conforms to the UIActivityItemSource protocol and
  • offers an animated GIF file by returning an NSURL of a .gif file and CFBridgingRelease(kUTTypeGIF) in the appropriate methods.

I如果我在新的邮件中共享我的一个对象,请参阅在模拟器中移动的GIF。如果我尝试发推文相同的内容,图片的一个框架会附加到推文上,但它会作为静止图像上传。

I see the GIF moving in the Simulator if I share one of my objects in a new Mail message. If I try tweeting the same thing, a frame of the image is attached to the tweet, but it's uploaded as a still image.

我是否需要等待Apple才能在未来的iOS版本中更新 UIActivityTypePostToTwitter ,还是我错过了你在某处看到过的变通办法? (我意识到这个案例没有使用Twitter.com,Android和iPhone [app]列表中的任何内容。这可能是徒劳的请求。)

Do I need to wait for Apple to update UIActivityTypePostToTwitter in a future iOS version, or have I missed a workaround you've seen somewhere? (I realize this case isn't using anything from the list "Twitter.com, Android and iPhone [app]". This is probably a futile plea.)

已完成作业:


  • 我知道 Twitter活动类型也可以与ALAsset对象一起使用,并且人们通过将数据保存在ALAssets中来获取进出已保存照片的GIF动画,但我希望能够如果可能的话,在不触碰相机胶卷的情况下发推这些GIF。

  • 我检查了 NSHipster

  • 我尝试为我的本地.gif返回 NSData 对象而不是 NSURL 来自Lyndsey关于Twitter API的提示。没有变化。

  • 我尝试返回 kUTTypeData 而不是 kUTTypeGIF Twitter API文档中看到此内容之后的 dataTypeIdentifierForActivityType

  • I know that the Twitter activity type can also work with an ALAsset object, and people get animated gifs into and out of Saved Photos by keeping their data wrapped up in ALAssets, but I want to be able to tweet these gifs without touching the Camera Roll, if possible.
  • I checked NSHipster.
  • I tried returning an NSData object instead of an NSURL for my local .gif file on a tip from Lyndsey about the Twitter API. No change.
  • I tried returning kUTTypeData instead of kUTTypeGIF as the dataTypeIdentifierForActivityType after seeing this in the Twitter API docs:



传递的图像应该是图像或二进制base64编码的原始二进制文件,否则不需要只要Content-Type设置得恰当(有疑问:application / octet-stream),就可以对内容进行编码或转义。

The image passed should be the raw binary of the image or binary base64 encoded, no need to otherwise encode or escape the contents as long as the Content-Type is set appropriately (when in doubt: "application/octet-stream").


但我的推文中没有出现任何图片。

but then no image appeared in my tweet.

谢谢!

推荐答案

遇到类似的问题并且谷歌搜索了很多但仍然不是一个完美的解决方案,我提出的最好的就是:

Encountered the similar problem and Googled a lot but still not a perfect solution, the best I came up is here:

使用UIActivityItemProvider并扩展 - (id)item {}以获取不同的UIActivityType:

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

Twitter :默认的UIActivityViewController Twitter共享还不支持它,它将缩小它作为一个静止的JPG。但不知何故,它适用于GIF小于100kb(在iOS 9测试),我不知道为什么。因此,我必须按照这里。完成SLRequest并返回后,关闭UIActivityViewController。其缺点是没有预览共享表,用户无法再输入自己的消息。

Twitter: The default UIActivityViewController Twitter share doesn't support it yet which it will "scale down" it as a still JPG. However somehow it works for GIF less than 100kb (tested in iOS 9) and I don't know why. Therefore, I have to use SLRequest to upload the GIF as taught in here. When the SLRequest is done and return, dismiss the UIActivityViewController. The downside of that is no preview share sheet and users cannot type their own message anymore.

- (id)item
{    
    if ([self.activityType isEqualToString:UIActivityTypePostToFacebook]) {
        // Upload to Giphy
        ...
        return [NSURL URLWithString:giphyURL];
    }
    if ([self.activityType isEqualToString:UIActivityTypePostToTwitter]) {
        // Use SLRequest to share instead
        ...
        // Dismiss the UIActivityViewController (I am using Unity)
        [UnityGetGLViewController() dismissViewControllerAnimated:NO completion: NULL];
        return nil;
    }
}

完整代码在我的 GitHub ,我实际上是iOS新手,所以有些专家请尽可能纠正我和代码

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

这篇关于我可以从UIActivityViewController和原生的UIActivityTypePostToTwitter发送动画GIF吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆