0

在我的项目中,我有 5 个级别。在第一级和第二级,我可以一次移动和射击。完成第二级后,我想与 Facebook 分享。facebook分享后,我不能一次移动和射击。只有一个进程在工作(射击或移动)。我想做什么来解决这个问题。

我的编码在这里:

{
UIViewController*v=[[UIViewController alloc]init];
[[[CCDirector sharedDirector]openGLView]addSubview:v.view];
SLComposeViewController*mySLComposerSheet;
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) 
{

    NSString *strg=[NSString stringWithFormat:@" "];

    NSString *bodyStr=[NSString stringWithFormat:@"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"!\n;


    mySLComposerSheet = [[SLComposeViewController alloc] init]; 
    mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; //Tell him with what social plattform to use it, e.g. facebook or twitter
    [mySLComposerSheet setInitialText:bodyStr]; //the message you want to post
    [mySLComposerSheet addImage:[UIImage imageNamed:@"my.jpg"]]; //an image you could post

    NSURL *url = [NSURL URLWithString:@"https:example.com"];
    [mySLComposerSheet addURL:url];


    [v presentViewController:mySLComposerSheet animated:YES completion:nil];
}
[mySLComposerSheet setCompletionHandler:^(SLComposeViewControllerResult result) {
    NSString *output,*head;
    switch (result) {
        case SLComposeViewControllerResultCancelled:
            output = @"FREE levels NOT unlocked";
            head=@"Facebook Share Unsuccessfull";
            UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:head message:output delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert1 show];
            [self reload];
            break;
        case SLComposeViewControllerResultDone:
            output = @"Extra FREE levels successfully unlocked";
            head=@"Successfull";
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:head message:output delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alert show];
            alert.tag=22;
                  break;
        default:
            break;
    } 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Facebook" message:output delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show];
}];

}
4

1 回答 1

0

您正在展示 ViewControllermySLComposerSheet

[v presentViewController:mySLComposerSheet animated:YES completion:nil];

但是您的completionHandler 中没有dismiss...语句

[self dismissViewControllerAnimated:YES completion:nil];

见帖子https://stackoverflow.com/a/12651085/2787026

于 2013-09-17T09:52:29.457 回答