2013-07-26 25 views
2

我使用這些代碼來顯示在iOS5的模擬器的Twitter對話在iOS5模擬器中使用TWTweetComposeViewController時如何知道設置按鈕點擊?

-(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]; 
} 

嘰嘰喳喳的默認AlertView顯示:

enter image description here

的問題是,當我點擊設置或取消按鈕,它總是去「取消」。 我需要抓住設置按鈕重定向到設置菜單。怎麼做?

回答

2

對於TWTweetComposeViewControllerResult,只有2個答案:

  • TWTweetComposeViewControllerResultCancelled
  • TWTweetComposeViewControllerResultDone

因此,不可能知道該用戶選擇設置或不。實際上,如果用戶選擇設置,那麼設置應用程序應該以默認行爲啓動。

更好的是,您應該通過canSendTweet方法檢查用戶是否正確配置了Twitter帳戶。如果方法返回NO,則不應出示TWTweetComposeViewController

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

+0

感謝您的信息。我在iOS6模擬器中測試,它的重定向OK。我沒有iOS5設備進行測試。不知道它可以重定向或不。 – Jack

+0

您可以使用模擬器來測試此功能。 – Raptor

+0

iOS5模擬器不重定向,與單擊取消操作相同 – Jack