2

I use these code to show twitter dialog in iOS5 simulator

-(void)showTwitter{
    TWTweetComposeViewController *tweet = [[TWTweetComposeViewController alloc] init];
    [tweet setInitialText:self.textView.text];
    [tweet setCompletionHandler:^(TWTweetComposeViewControllerResult result) {
        if (result == TWTweetComposeViewControllerResultDone) {
            NSLog(@"OK");
        }
        else{
            NSLog(@"CANCEL");
            //How to know setting button click to redirect to setting menu
            //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=TWITTER"]]; 
        }
        [self dismissModalViewControllerAnimated:YES];
    }];

    [self presentModalViewController:tweet animated:YES];
}

The default AlertView of twitter appear:

enter image description here

The problem is that when I click on Settings or Cancel button, it always go to "CANCEL". I need to catch setting button to redirect to setting menu. How to do that?

4

1 回答 1

2

对于TWTweetComposeViewControllerResult,只有 2 个答案:

  • TWTweetComposeViewControllerResultCancelled
  • TWTweetComposeViewControllerResultDone

因此,不可能知道用户是否选择了设置。事实上,如果用户选择设置,设置应用程序应该以默认行为启动。

更好的是,您应该通过canSendTweet方法检查用户是否正确配置了 Twitter 帐户。如果方法返回NO,则不应显示TWTweetComposeViewController.

参考:http: //developer.apple.com/library/ios/#documentation/Twitter/Reference/TWTweetSheetViewControllerClassRef/Reference/Reference.html

于 2013-07-26T02:48:40.517 回答