我在游戏中设置了一个按钮,您可以在其中发布您的分数。问题是,当用户发布推文时,我想打开一个新视图,而我不知道如何知道推文的发布时间。为了发布推文,我使用了这段代码:
-(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 :(得分:0)
您可以在tweetSheet上设置完成处理程序,如下所示:
[tweetSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
switch (result) {
case SLComposeViewControllerResultCancelled:
NSLog(@"Post Canceled");
break;
case SLComposeViewControllerResultDone:
NSLog(@"Post Sucessful");
break;
default:
break;
}
}];