0

我的应用程序以下列方式发送推文:

-(IBAction)TweetMethod:(id)sender{

tweetView = [[TWTweetComposeViewController alloc] init];
TWTweetComposeViewControllerCompletionHandler
completionHandler = ^(TWTweetComposeViewControllerResult result)
{
    switch (result)
    {
        case TWTweetComposeViewControllerResultCancelled:
            NSLog(@"Twitter Result: canceled");
            break;
        case TWTweetComposeViewControllerResultDone:
            NSLog(@"Twitter Result: sent");
            break;
        default:
            NSLog(@"Twitter Result: default"); break;
    }
    [self dismissModalViewControllerAnimated:YES]; };
[tweetView setCompletionHandler:completionHandler]; 

NSURL *url = [[NSURL alloc] initWithString:@"Twitter.com"];


UIButton *button = (UIButton*) sender;

for (UITextView *text in messagetext) 
{

    for (UITextView *name in messagename) 
    {


    if ([text isKindOfClass:[UITextView class]] && text.tag == button.tag && text.tag== name.tag)
    {

             [tweetView setInitialText:[NSString stringWithFormat:@"Event name: %@. Download the app to check out the full details, including location, at: ", name.text]];
    }

   }

}


[tweetView addImage:[UIImage imageNamed:@"smallIcon 144 ipad.png"]];
[tweetView addURL:url];
[self presentModalViewController:tweetView animated:YES];

}

我注意到,如果我保留这条线:

[tweetView addImage:[UIImage imageNamed:@"smallIcon 144 ipad.png"]];

出现图像,但蓝色按钮推文已关闭,因此我无法推文,而如果我删除该行,则没有图像,我可以推文。为什么??

4

1 回答 1

0

Twitter 有 140 个字符的限制!该推文可能与该图像太长。addImage/addURL 返回什么?如果它返回 NO,则推文太长。

另一个原因可能是您没有检查[TWTweetComposeViewController canSendTweet]. 用户必须在设置中设置了至少一个 Twitter 帐户。

于 2012-09-04T17:04:03.347 回答