iphone - working - Twitter Post iOS6 'Cancel' button issue




twitter troubleshooting (4)

Found the issue. It only happens when a completion handler is added to TWTweetComposeViewController. If added, make sure to call:

[self dismissModalViewControllerAnimated:YES];

I'm in the process of changing my app for iOS6 and iPhone use, I can't seem to figure out why when I post from Twitter using the new Social framework I have to press 'Cancel' twice to close, anybody else have this issue or a fix? Here is the code for the button.

- (IBAction)twitterPost:(id)sender
{
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
    mySLComposerSheet = [[SLComposeViewController alloc] init];
    mySLComposerSheet = [SLComposeViewController   composeViewControllerForServiceType:SLServiceTypeTwitter];
    [mySLComposerSheet setInitialText:[NSString stringWithFormat:@"This is my tweet, hello!",mySLComposerSheet.serviceType]];
    [self presentViewController:mySLComposerSheet animated:YES completion:nil];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
    NSLog(@"dfsdf");
    switch (result) {
        case SLComposeViewControllerResultCancelled:
            break;
        case SLComposeViewControllerResultDone:
            break;
        default:
            break;
    }
}];


}

If your using the mySLComposerSheet this works great...

[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
[mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];

Posting comment above as an answer:

Have you tried setting the completionHandler before presenting the View Controller?


Try this buddy

   [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {

        switch (result) {
            case SLComposeViewControllerResultCancelled:
                [self performSelector:@selector(showalert)];
                [mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
                break;
            case SLComposeViewControllerResultDone:
                [self performSelector:@selector(showalert1)];
                [mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
                break;

            default:
                break;


        }
    }];