2015-06-19 61 views
0

我在遊戲中設置了一個按鈕,您可以在其中發佈您的分數。問題是,當用戶剛剛發佈推文時,我想打開一個新視圖,而且我不知道如何知道推文何時發佈。對於發佈我用這個代碼的鳴叫:tweet發佈後的動作

-(void)shareTwitter { 
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { 
    SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; 

    [tweetSheet setInitialText:[NSString stringWithFormat:@"I've just scored 98 points!]; 

    UIViewController *controller = self.view.window.rootViewController; 
    [controller presentViewController:tweetSheet animated:YES completion:nil]; 

} 

}

回答

0

您可以設置完成處理您tweetSheet像這樣:

[tweetSheet setCompletionHandler:^(SLComposeViewControllerResult result) { 

     switch (result) { 
      case SLComposeViewControllerResultCancelled: 
       NSLog(@"Post Canceled"); 
       break; 
      case SLComposeViewControllerResultDone: 
       NSLog(@"Post Sucessful"); 
       break; 

      default: 
       break; 
     } 
    }]; 
+0

非常感謝! :) –