当用户无法向Twitter发送消息时,我该怎么办?

时间:2012-02-15 14:16:46

标签: ios ios5 twitter

我有应用程序,可以发送twits。

我是这样做的:

- (IBAction)twitDream:(id)sender
{
    if ([TWTweetComposeViewController canSendTweet]) {
        TWTweetComposeViewController *tweet = 
        [[TWTweetComposeViewController alloc] init];
        if (dream.image != [UIImage imageNamed:@"blank-photo.png"])
        [tweet addImage:dream.image];
        NSString *twitMsg = [dreamField.text stringByAppendingString:@" send via Dreamer"];
        [tweet setInitialText:twitMsg];
        [self presentModalViewController:tweet animated:YES];
    } else {
        //can't tweet!
    }
}

[TWTweetComposeViewController canSendTweet]等于NO时,我该怎么办?当它等于NO

1 个答案:

答案 0 :(得分:1)

这是完整的解决方案代码:

- (IBAction)twitDream:(id)sender
{
    if ([TWTweetComposeViewController canSendTweet]) {
        TWTweetComposeViewController *tweet = 
        [[TWTweetComposeViewController alloc] init];
        if (dream.image != [UIImage imageNamed:@"blank-photo.png"]) {[tweet addImage:dream.image];}
        NSString *twitMsg = [dreamField.text stringByAppendingString:@" #Dreamer"];
        [tweet setInitialText:twitMsg];
        [self presentModalViewController:tweet animated:YES];
    } else {
        UIAlertView *alertView = [[UIAlertView alloc] 
                                  initWithTitle:@"Sorry"                                                             
                                  message:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup"                                                          
                                  delegate:self                                              
                                  cancelButtonTitle:@"OK"                                                   
                                  otherButtonTitles:nil];
        [alertView show];
    }
}