<tfoot id='g7mCy'></tfoot>
      <bdo id='g7mCy'></bdo><ul id='g7mCy'></ul>
  • <i id='g7mCy'><tr id='g7mCy'><dt id='g7mCy'><q id='g7mCy'><span id='g7mCy'><b id='g7mCy'><form id='g7mCy'><ins id='g7mCy'></ins><ul id='g7mCy'></ul><sub id='g7mCy'></sub></form><legend id='g7mCy'></legend><bdo id='g7mCy'><pre id='g7mCy'><center id='g7mCy'></center></pre></bdo></b><th id='g7mCy'></th></span></q></dt></tr></i><div id='g7mCy'><tfoot id='g7mCy'></tfoot><dl id='g7mCy'><fieldset id='g7mCy'></fieldset></dl></div>
  • <legend id='g7mCy'><style id='g7mCy'><dir id='g7mCy'><q id='g7mCy'></q></dir></style></legend>

        <small id='g7mCy'></small><noframes id='g7mCy'>

        TWTweetComposeViewController 中的错误?

        时间:2023-05-17

        <small id='Alsol'></small><noframes id='Alsol'>

        <i id='Alsol'><tr id='Alsol'><dt id='Alsol'><q id='Alsol'><span id='Alsol'><b id='Alsol'><form id='Alsol'><ins id='Alsol'></ins><ul id='Alsol'></ul><sub id='Alsol'></sub></form><legend id='Alsol'></legend><bdo id='Alsol'><pre id='Alsol'><center id='Alsol'></center></pre></bdo></b><th id='Alsol'></th></span></q></dt></tr></i><div id='Alsol'><tfoot id='Alsol'></tfoot><dl id='Alsol'><fieldset id='Alsol'></fieldset></dl></div>
          <tbody id='Alsol'></tbody>
            <bdo id='Alsol'></bdo><ul id='Alsol'></ul>

          • <legend id='Alsol'><style id='Alsol'><dir id='Alsol'><q id='Alsol'></q></dir></style></legend>
              1. <tfoot id='Alsol'></tfoot>

                  本文介绍了TWTweetComposeViewController 中的错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在使用 TWTweetComposeViewController(如果可用)从我的 iOS 应用程序内部发送推文.我使用样板文本预先填充视图控制器,然后让用户自行修改和发送.它在大多数情况下都很好用.蒸馏下来,它看起来像这样(body 指向一个有效的 NSString):

                  I am using TWTweetComposeViewController, when available, to send tweets from inside my iOS app. I pre-populate the view controller with boilerplate text, then let the user modify and send at their discretion. It works great for the most part. Distilled down, it looks like this (with body pointing at a valid NSString):

                  if (NSClassFromString(@"TWTweetComposeViewController"))  {
                      TWTweetComposeViewController *iOS5twitter = [[TWTweetComposeViewController alloc] init];
                      [iOS5twitter setInitialText:body];
                      iOS5twitter.completionHandler = ^(TWTweetComposeViewControllerResult result) 
                      {
                          [self.viewController dismissViewControllerAnimated:YES completion:nil];
                      };   
                      [self.viewController presentViewController:iOS5twitter animated:YES completion:nil];
                      [iOS5twitter release];
                  }
                  else {
                      /* Do something else when the framework is missing */
                  }
                  

                  现在如果 body 太长,即超过 140 个字符,则生成的推文视图根本没有任何文本,字符倒计时设置为 140.在这种情况下,我可能预计会截断,虽然它似乎没有在类参考中以一种或另一种方式记录在初始文本太长时会发生什么,但我可以接受在传递给 setInitialText 之前我必须截断到最大推文长度.

                  Now if body is too long, i.e., more than 140 characters, the resulting tweet view is empty of any text at all, character countdown set to 140. I might have expected truncation in this case, although it does not appear to be documented in the Class Reference one way or the other what happens when the initial text is too long, but I can accept that I have to do the truncation to maximum tweet length before passing to setInitialText.

                  我不明白的是,某些短于 140 个字符的消息也会产生空的推文视图.

                  What I don't understand is that certain messages which are shorter than 140 characters also produce the empty tweet view.

                  最初,我看到一个似乎完全有效的字符串,但失败了 139 个字符.我注意到缩短字符串使它起作用.但经过大量试验后,我还注意到,用相同长度的随机文本替换恰好出现在文本中的 URL 可以正常工作.换句话说,是 URL 本身造成了问题.

                  Initially I saw what seemed to be a perfectly valid string with 139 characters failing. I noticed that shortening the string made it work. But after a great deal of experimenting, I also noticed that replacing a URL which happened to appear inside the text with random text of the same length made it work. In other words, the URL itself is causing a problem.

                  所以我认为我使用的 URL 可能有些奇怪,但我将其提炼成这一点.这个有效:

                  So I thought maybe there was something weird about the URL I was using, but I distilled it down to this. This one works:

                  NSString *body = @"............................................................................................................................................";
                  

                  虽然没有

                  NSString *body = @"............http://a........................................................................................................................";
                  

                  观察:

                  • 它们都是 140 个字符长(并在控制台中使用 [body length] 以这种方式报告).唯一的区别是在第二个的中间嵌入了一些类似 URL 的东西.
                  • 字符串中 URL 的位置似乎无关紧要,但如果我将这些非句点字符中的任何一个更改为句点(从而使其不再像 URL),它将不再被破坏.
                  • 如果我缩短损坏的部分,将末尾的 14 个句点剪掉,它会起作用.也就是说,这个特殊的 URL 嵌入在句点中,总长度为 126 个字符.127 或更大的已损坏.不清楚这与 URL 本身的长度如何或是否相关.
                  • They are both 140 characters long (and report that way in the console with [body length]). The only difference is the presence of something vaguely URL-like embedded in the middle of the second one.
                  • The position of the URL within the string does not seem to matter, but if I change any one of those non-period characters to a period (thus making it not like a URL anymore), it ceases to be broken.
                  • If I shorten the broken one, shaving 14 periods off the end, it works. That is, this particular URL embedded in periods for a total length of 126 characters is fine. 127 or larger is broken. Not clear how, or if, this relates to the length of the URL itself.

                  有人见过这样的吗?知道发生了什么吗?是我做错了什么,还是 iOS Twitter 框架刚刚损坏?

                  Anybody ever seen something like this? Any idea what is going on? Am I doing something wrong, or is the iOS Twitter Framework just broken?

                  推荐答案

                  我遇到了完全相同的问题.这是 Twitter 框架中的一个已知错误,正在跟踪中.

                  I have run into the exact same problem. It is a known bug in the Twitter framework and is being tracked.

                  请在 dev.twitter.com 上查看此讨论 https://dev.twitter.com/discussions/5024

                  Please see this discussion on dev.twitter.com https://dev.twitter.com/discussions/5024

                  (如果可以的话,我会把它作为评论而不是答案发布,但我没有足够的可信度,所以我想我也会添加以下观察结果,以防它们感兴趣).

                  (I would have posted that as a comment rather than an answer if I could, but I don't have sufficient SO credibility so thought I'd add the below observations as well in case they are of interest).

                  仅添加不带 URL 的文本时,字符数按预期工作.使用 addURL: 方法添加 URL 会导致使用 21 个字符的推文(20 个用于 URL 加上一个空格).在初始文本中添加 URL 会导致 URL 使用 20 个字符.当包含单个 URL(使用任一方法)时,当总字符数超过 138(例如,URL 为 20 + 空格 + 初始文本的 117 个字符)时,框架会失败,因此会丢失 2 个字符.只有一个 URL,设置初始文本然后使用 addURL: 添加 URL 的顺序没有区别.

                  When just adding text without URLs, the character count works as expected. Adding a URL with the addURL: method causes 21 characters of the tweet to be used (20 for URL plus a space). Adding the URL in the initial text causes 20 chars to be used for the URL. When including a single URL (using either method) the framework fails when the total character count exceeds 138 (e.g. 20 for URL + space + 117 chars of initial text) thus losing 2 characters. With just one URL the order of setting the initial text and then adding the URL with addURL: does not make a difference.

                  当添加 2 个 URls 时,当总字符数超过 113 时它会失败,这会丢失 27 个字符!但是,如果有 2 个或更多,如果您在 BEFORE 设置初始文本时添加 URL,则会失败,总数为 136.因此每个 URL 再次丢失 2 个字符.

                  When adding 2 URls, it fails when the total character count exceeds 113 this losing 27 characters! However, with 2 or more, if you add the URLs BEFORE setting the initial text, it fails with a total count of 136. So 2 chars are lost per URL again.

                  总结/解决方法 - 如果只包含 1 个 URL,那么在初始文本中添加它会比使用 addURL: 方法多出一个字符,但总体上仍然会少 2 个字符.如果使用 addURL: 添加 2 个或更多 URL,则在初始文本之前添加它们,但在修复错误之前,每个 URL 仍然会丢失 2 个字符.

                  Summary/Workaround - if just including 1 URL then adding it in the initial text will give you one extra character than using the addURL: method, but you will still be short 2 characters overall. If adding 2 or more URLs using addURL: then add them before the initial text, but until the bug is fixed, you will still lose 2 chars per URL.

                  我已经提交了雷达,但是根据这个 我可以浏览其他人 (Apple) 的错误报告?,错误报告的次数越多,它的优先级就越高,因此值得其他人也提交它以提高它的优先级.

                  I have filed a radar, but according to this Can I browse other people's (Apple) bug reports?, the more times a bug is reported the higher priority it is given, so it is worth others filing it as well to increase it's priority.

                  这篇关于TWTweetComposeViewController 中的错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:带有 libxml 的 Swift 框架 下一篇:iOS8:自定义 Swift 框架访问用 Objective-C 编写的外部框架

                  相关文章

                  • <bdo id='u3Cqu'></bdo><ul id='u3Cqu'></ul>

                  1. <tfoot id='u3Cqu'></tfoot>

                    <legend id='u3Cqu'><style id='u3Cqu'><dir id='u3Cqu'><q id='u3Cqu'></q></dir></style></legend>
                    <i id='u3Cqu'><tr id='u3Cqu'><dt id='u3Cqu'><q id='u3Cqu'><span id='u3Cqu'><b id='u3Cqu'><form id='u3Cqu'><ins id='u3Cqu'></ins><ul id='u3Cqu'></ul><sub id='u3Cqu'></sub></form><legend id='u3Cqu'></legend><bdo id='u3Cqu'><pre id='u3Cqu'><center id='u3Cqu'></center></pre></bdo></b><th id='u3Cqu'></th></span></q></dt></tr></i><div id='u3Cqu'><tfoot id='u3Cqu'></tfoot><dl id='u3Cqu'><fieldset id='u3Cqu'></fieldset></dl></div>

                      <small id='u3Cqu'></small><noframes id='u3Cqu'>