TwitterKit iOS SDK 根据字符数计算图像和 URL [英] TwitterKit iOS SDK counting image and URL against character count

查看:28
本文介绍了TwitterKit iOS SDK 根据字符数计算图像和 URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是最新版本的 TwitterKit (2.5),当我尝试分享带有图像和 URL 的推文时,TWTRComposer 会根据字符数计算它们.Twitter 应该不再根据字符数计算媒体,事实上,我可以从网络上发布完全相同的推文,而我无法在应用内发布(应用说它太长了).

I am using the latest version of TwitterKit (2.5), and when I attempt to share a Tweet with an image and URL, the TWTRComposer is counting them against the character count. Twitter is supposed to no longer count media against the character count, and in fact I am able to post the exact same tweet from the web that I cannot post in-app (app says it is too long).

在我当前的用例中,我的实际推文文本是 100 个字符.通过图像和 URL,TWTRComposer 显示我超过限制 8 个字符.然而,我可以发布这条完全相同的推文,内容与 Chrome 中的完全相同,但有 16 个字符可以保留.

In my current use case, my actual tweet text is 100 characters. With an image and URL, TWTRComposer is showing that I am 8 characters over the limit. Yet, I can post this exact same Tweet with the exact same content from Chrome with 16 characters to spare.

这是一个已知的错误吗?

Is this a known bug?

代码片段:

func didTapShareToTwitter() {
        // Configure composer
        let composer = TWTRComposer()

        composer.setText(composerText)          
        composer.setURL(shareURL)

        if shareImageURL != nil {
            if let imageData = NSData(contentsOfURL: shareImageURL!) {
                composer.setImage(UIImage(data: imageData))
            }
        }

        // Present composer
        composer.showFromViewController(self) { result in
            if (result == TWTRComposerResult.Cancelled) {
                log("Tweet composition cancelled.")
            }
            else {
                log("Sending tweet...")
            }
        }

    }

推荐答案

看起来这是一个 iOS 系统级错误,不一定是 Twitter SDK.TWTRComposer 实际上只是对内置的 iOS 共享视图控制器 SLComposeViewController 的封装.

Looks like this an iOS system-level bug, not necessarily the Twitter SDK. The TWTRComposer is actually just a wrapper around the built-in iOS sharing view controller, SLComposeViewController.

截至最新的 iOS 版本 10.1,iOS SLComposeViewController 仍然根据 Twitter 总字符数限制 (140) 计算附加的 URL 和图像.最有可能的是,自从 Twitter 在今年早些时候采取行动,不根据字符限制计算图像和 URL 后,Apple 还没有更新他们的操作系统代码.

The iOS SLComposeViewController still counts attached URLs and images against the total Twitter character limit (140) as of the latest iOS release, 10.1. Most likely, Apple just hasn’t updated their OS code since Twitter made the move to not count images and URLs against the character limit earlier this year.

经过一些测试,我得出以下结论:

After doing some testing, I have come to the following conclusion:

  • 在 iOS 上,无论原始长度如何,URL 都计为 23 个字符网址是.
  • 在 iOS 上,不管怎样,一张图片都算作 23 个字符它是大小.
  • 因此,对于图像和 URL,我们只有 94 个字符
    每个推文在 iOS 上可用.没有什么可以做的
    除非 Twitter 更新他们的 SDK 或 Apple 更新SLComposeViewController.

这篇关于TwitterKit iOS SDK 根据字符数计算图像和 URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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