将SLComposeViewController实现到Cocos2d中

时间:2013-04-25 08:23:49

标签: cocos2d-iphone slcomposeviewcontroller

我似乎无法让SLComposeViewController来自cocos2D图层上的按钮。如果你能看到任何会阻止这项工作的事情,请告诉我们。任何帮助将不胜感激:N.B。 viewController是一个UIViewController

-(void)sceneSelect
{
    NSString *message = [NSString stringWithFormat:@"Twitter Message"];

    NSString *serviceType = [NSString stringWithFormat:@"SLServiceTypeTwitter"];


    if ([SLComposeViewController isAvailableForServiceType:serviceType])
    {
        SLComposeViewController *tweetController = [SLComposeViewController composeViewControllerForServiceType:serviceType];
        [tweetController setInitialText:message];

        tweetController.completionHandler = ^(SLComposeViewControllerResult result){


            if (result == SLComposeViewControllerResultDone){
               //NSLog call
            }
            else if (result == SLComposeViewControllerResultCancelled){
               //NSLog call
            }

            [viewController dismissViewControllerAnimated: YES completion: nil];
        };

        [[[CCDirector sharedDirector]openGLView]addSubview:viewController.view];
        [viewController presentViewController:tweetController animated:YES completion:nil];
    }

    else
    {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Twitter" message:@"Twitter not working" delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];

        [alertView show];
    }
}

1 个答案:

答案 0 :(得分:0)

然后

Cocos2d 2.0在AppDelegate中使用导航控制器

    AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
    [[app navController] presentModalViewController:tweetController animated:YES];

这是我的完整的TWIT代码:http://pastebin.com/hpRRJM1n