示例项目: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];
它坏了吗?我必须围绕这个编码吗?