【问题标题】:Is Twitter sharing broken under iOS 7? (Example project attached.)在 iOS 7 下 Twitter 分享会被破坏吗? (附上示例项目。)
【发布时间】:2013-11-22 17:06:05
【问题描述】:

示例项目:http://cl.ly/261z1P100T25

在 iOS 7 下,当我尝试将 URL 添加到推文时,如果没有足够的空间来添加它,该方法应该返回 NO(“如果 url 不适合当前可用的字符空间,则此方法返回 NO”)但此方法在 iOS 7 中始终返回 YES。例如,在以下示例中,“无法添加”。永远不会打印,并且推文显示剩余 -32 个字符。

SLComposeViewController *twitterViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
NSString *titleToShare = @"i am a string a super string the most super string that ever existed in the world of the super string universe which as it happens is very super as well";

if (titleToShare.length > 140) {
    titleToShare = [titleToShare substringToIndex:140];
}

[twitterViewController setInitialText:titleToShare];

if (![twitterViewController addURL:[NSURL URLWithString:@"http://google.com"]]) {
    NSLog(@"Couldn't add.");
}

[self presentViewController:twitterViewController animated:YES completion:nil];

它坏了吗?我必须围绕这个编写代码吗?

【问题讨论】:

    标签: ios objective-c twitter ios7 slcomposeviewcontroller


    【解决方案1】:

    它没有损坏,只是没有很好地公开记录。我在 setInitialText: 方法的注释后面的代码中发现:

    // Sets the initial text to be posted. Returns NO if the sheet has already been
    // presented to the user. On iOS 6.x, this returns NO if the specified text
    // will not fit within the character space currently available; on iOS 7.0 and
    // later, you may supply text with a length greater than the service supports,
    // and the sheet will allow the user to edit it accordingly.
    

    因此,它们允许您设置大于 140 个字符的文本,只是您无法发布此文本,因为发布按钮已禁用。

    【讨论】:

      猜你喜欢
      • 2020-02-15
      • 2021-01-13
      • 2013-12-02
      • 2015-03-03
      • 2012-10-11
      • 2014-06-05
      • 2014-01-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多