0

I've been upgrading my app to use both FB and Twitter posting... I had upgraded from the original twitter functions but now when the FBSheet and Twitter Sheets come up and I post the messages,the app loses focus and I can no longer access the screen below it. Here is my case statement for the postings... I can't find anything obvious.

int social_status = 0;
if (twitterEnabled) {
    social_status=1;
}
if (facebookEnabled) {
    social_status=2;
}
if (twitterEnabled && facebookEnabled) {
    social_status = 3;
}

switch (social_status ) {
    case kTwitterOn:{

        SLComposeViewController *tweetSheet =[[SLComposeViewController alloc] init];
        // Sets viewcontroller to twitter type
        tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter];
        SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
            [tweetSheet dismissViewControllerAnimated:YES completion:nil];

            switch(result){
                case SLComposeViewControllerResultCancelled:
                default:
                {
                    NSLog(@"Cancelled.....");

                }
                    break;
                case SLComposeViewControllerResultDone:
                {
                    NSLog(@"Posted....");
                }
                    break;
            }};
        tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter];
        [tweetSheet setInitialText:message];
        [tweetSheet setCompletionHandler:completionHandler];
        [self presentViewController:tweetSheet animated:YES completion:nil];
        tweetSheet=nil;
    }
        break;

    case kFacebookOn: {
        SLComposeViewController *faceBookSheet=[[SLComposeViewController alloc] init];
        // Sets viewcontroller to FB type
        faceBookSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook];
        SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
            [faceBookSheet dismissViewControllerAnimated:YES completion:nil];

            switch(result){
                case SLComposeViewControllerResultCancelled:
                default:
                {
                    NSLog(@"Cancelled.....");

                }
                    break;
                case SLComposeViewControllerResultDone:
                {
                    NSLog(@"Posted....");
                }
                    break;
            }
        };
        //Calls the function for set Text
        [faceBookSheet setInitialText:message];
        [faceBookSheet setCompletionHandler:completionHandler];
        //Presenting the FB sheet
        [self presentViewController:faceBookSheet animated: YES completion: nil];
        faceBookSheet=nil;
    }
        break;

    case kTwitterAndFacebookOn:{

        SLComposeViewController *tweetSheet =[[SLComposeViewController alloc] init];
        // Sets viewcontroller to twitter type
        tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter];
        SLComposeViewControllerCompletionHandler __block completionHandler=^(SLComposeViewControllerResult result){
            [tweetSheet dismissViewControllerAnimated:YES completion:nil];

            switch(result){
                case SLComposeViewControllerResultCancelled:
                default:
                {
                    NSLog(@"Cancelled.....");
                }
                    break;
                case SLComposeViewControllerResultDone:
                {
                    NSLog(@"Posted....");
                }
                    break;
            }
        };
        tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter];
        [tweetSheet setInitialText:message];
        [tweetSheet setCompletionHandler:completionHandler];
        [self presentViewController:tweetSheet animated:YES completion:nil];
        tweetSheet=nil;

        SLComposeViewController *faceBookSheet=[[SLComposeViewController alloc] init];
        // Sets viewcontroller to FB type
        faceBookSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeFacebook];
        SLComposeViewControllerCompletionHandler __block completionHandler2=^(SLComposeViewControllerResult result){
            [faceBookSheet dismissViewControllerAnimated:YES completion:nil];

            switch(result){
                case SLComposeViewControllerResultCancelled:
                default:
                {
                    NSLog(@"Cancelled.....");
                }
                    break;
                case SLComposeViewControllerResultDone:
                {
                    NSLog(@"Posted....");
                }
                    break;
            }
        };
        //Calls the function for set Text
        [faceBookSheet setInitialText:message];
        [faceBookSheet setCompletionHandler:completionHandler2];
        //Presenting the FB sheet
        [self presentViewController:faceBookSheet animated: YES completion: nil];
        faceBookSheet=nil;
    }
        break;

    default:
    {
        // We show this Alert if there is no Twitter Enablement
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Quorum Reached" message:message delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
        [alert show];
    }
        break;
}

Any suggestions?

4

1 回答 1

0

好的..我发现我复制了这条线 tweetSheet=[SLComposeViewController composeViewControllerForServiceType: SLServiceTypeTwitter]; 所以这导致了问题......

于 2013-05-05T20:49:28.767 回答