Twitter Post iOS6 'Cancel' button issue

后端 未结 5 629
既然无缘
既然无缘 2021-01-04 04:13

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 \'Can

相关标签:
5条回答
  • 2021-01-04 04:54

    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;
    
    
            }
        }];
    
    0 讨论(0)
  • 2021-01-04 04:57

    If your using the mySLComposerSheet this works great...

    [mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
    [mySLComposerSheet dismissViewControllerAnimated:YES completion:nil];
    
    0 讨论(0)
  • 2021-01-04 04:59

    My experience with SLComposeViewController is that twitter and weibo controllers need to be dismissed manually while the facebook controller seems to be better behaved.

    If I don't dismissViewControllerAnimated myself, tapping the "Send" button will send the tweet or weibo posting but I'll be left with what seems to be an invisible view over my own view. Thus I can no longer interact with my app.

    I don't know why my app is working like this... Interestingly, the completionHandler for cancel gets called just once. The second tap dismisses the view controller.

    + (void) shareText:(NSString*)text image:(UIImage*)image social:(NSString*)service url:(NSString*)url
    {
        SLComposeViewController*    controller = [SLComposeViewController composeViewControllerForServiceType:service];
    
        [controller setInitialText:text];
        [controller addImage:image];
        [controller addURL:[NSURL URLWithString:url]];
    
        controller.completionHandler = ^(SLComposeViewControllerResult result) {
            if( SLComposeViewControllerResultDone == result )
            {
                NSLog(@"rewards for share: %@!", service );
            }
            if( ![SLServiceTypeFacebook isEqualToString:service] )  // facebook behaves
                [[CBLAppDelegate instance].activeViewController dismissViewControllerAnimated:true completion:nil];
        };
        [[CBLAppDelegate instance].activeViewController presentViewController:controller animated:true completion:nil];
    }
    
    0 讨论(0)
  • 2021-01-04 05:10

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

    [self dismissModalViewControllerAnimated:YES];

    0 讨论(0)
  • 2021-01-04 05:12

    Posting comment above as an answer:

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

    0 讨论(0)
提交回复
热议问题