CoCoS2D2.0升级后Twitter不再工作

CoCoS2D2.0升级后Twitter不再工作,twitter,uiviewcontroller,cocos2d-iphone,Twitter,Uiviewcontroller,Cocos2d Iphone,我有一个项目,使用Twitter API向用户推特高分。该项目是使用cocos2dv1.1编写的,一切正常。我最近启动了一个新项目,使用cocos2dv2.0,并试图使用我的另一个项目中的相同代码来整合相同的Twitter功能,但按下Tweet按钮时,viewcontroller将不会出现。下面是我正在使用的代码 if ([TWTweetComposeViewController canSendTweet]) // Check if twitter is setup and reachable

我有一个项目,使用Twitter API向用户推特高分。该项目是使用cocos2dv1.1编写的,一切正常。我最近启动了一个新项目,使用cocos2dv2.0,并试图使用我的另一个项目中的相同代码来整合相同的Twitter功能,但按下Tweet按钮时,viewcontroller将不会出现。下面是我正在使用的代码

if ([TWTweetComposeViewController canSendTweet]) // Check if twitter is setup and reachable
    {
        CCLOG(@"Can Tweet");
        TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];

        // set initial text
        NSString *theTweet = @"The message..."];
        [tweetViewController setInitialText:theTweet];

        // setup completion handler
        tweetViewController.completionHandler = ^(TWTweetComposeViewControllerResult result) {
            if(result == TWTweetComposeViewControllerResultDone) {
                // the user finished composing a tweet

            } else if(result == TWTweetComposeViewControllerResultCancelled) {
                 // the user cancelled composing a tweet
            }
            [viewController dismissViewControllerAnimated:YES completion:nil];
        };

        // present view controller
        [[[CCDirector sharedDirector] openGLView] addSubview:viewController.view];
        [viewController presentViewController:tweetViewController animated:YES completion:nil];

    }
else
{
    // Twitter account not configured, inform the user
    NSLog(@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup");
}
我发现“openGLView”现在被贬值了,我用“view”代替了它。这仍然不起作用。不过,这种方法是可行的。我已经包含了一个CCLOG,它返回字符串“Can Tweet”,并显示在输出窗口中。有没有人对如何让它发挥作用有什么建议。如果我需要提供更多信息,请告诉我


谢谢

在cocos2d 2.0中使用此代码

AppController * app = (((AppController*) [UIApplication sharedApplication].delegate));

        TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];

        [tweetViewController setInitialText:string];

        [tweetViewController setCompletionHandler:^(TWTweetComposeViewControllerResult result) {

            dispatch_async(dispatch_get_main_queue(), ^{

                {
                    if (result == TWTweetComposeViewControllerResultDone)
                    {
                        //successful
                        [[NSNotificationCenter defaultCenter] postNotificationName:@"PPTweetSuccessful" object:nil];

                    }
                    else if(result == TWTweetComposeViewControllerResultCancelled)
                    {
                        //Cancelled
                    }
                }

                [app.navController dismissModalViewControllerAnimated:YES];

                [tweetViewController release];
            });

        }];

        [app.navController presentModalViewController:tweetViewController animated:YES];