0

I'm using Social framework in my project (iOS6), so user can make posts on Facebook or Twitter.

My question is, if there is a way to find out if user have sent a post to social network or he have canceled it and haven't published anything?

I use this code to share posts on Twitter:

-(IBAction)askOnTwitter
{   
    if (SYSTEM_VERSION_LESS_THAN(@"6.0"))
    {
        [self showErrorAlert];
        twitterButton.enabled = NO;
        return;
    }

    if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) 
    {
        slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

        [slComposeViewController setInitialText:@"Hey"];

        [self presentViewController:slComposeViewController animated:YES completion:nil];

        // So have user published a post or he haven't? How to know?
    }
}

Does somebody know the trick? Thanks in advance.

4

1 回答 1

2

您可以为撰写视图控制器设置完成处理程序。在那里你会得到结果SLComposeViewControllerResultDoneSLComposeViewControllerCancelled

  __block __weak SLComposeViewController *slComposeViewController = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

 [slComposeViewController setCompletionHandler:^
     (SLComposeViewControllerResult result){

      if (result == SLComposeViewControllerResultDone) {
             NSLog(@"Done successfully");
         }
         else{
             NSLog(@"Cancelled");
         }

         [slComposeViewController dismissViewControllerAnimated:YES completion:nil];
     }];
于 2013-06-10T04:29:32.513 回答