ios - 新的 View Controller 出现然后消失在 CCScene 后面

标签 ios uiviewcontroller cocos2d-iphone

我正在努力整合 Ben Gottlieb's Twitter-OAuth-iPhone使用 this tutorial 编码到我的 cocos2d 0.99.5 项目中.我在让 View Controller 正确加载时遇到了一些困难。我以前从未将 cocos2d 与标准的 Cocoa Touch UI 东西混合在一起,我有点不知所云。

当需要连接到 Twitter 时,我在我的应用委托(delegate)中调用以下代码:

-(void) twitterAccountLogin
{
    UIViewController *controller = nil;
    if (!_engine) {
        _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self];
        _engine.consumerKey = kOAuthConsumerKey;
        _engine.consumerSecret = kOAuthConsumerSecret;

        controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];
    }

    if (controller) {
        [[CCDirector sharedDirector] stopAnimation];
        [viewController presentModalViewController:controller animated:YES];
        [controller release];
        return;
    }
} 

当它被调用时,Twitter UIViewController 被创建,它在屏幕上动画,然后,一旦它完成动画(即它到达屏幕顶部),它就会消失。当前运行的 CCScene 重新出现,但它不响应触摸。在模拟器上,不是重新出现运行场景,而是屏幕变黑。如果不清楚,viewController就是cocos2d最近在0.99.5中添加的RootViewController

在我看来,正在创建 UIViewController,然后以某种方式在运行场景下绘制,但调试让我无处可去。我哪里出错了?

最佳答案

你的 View Controller 应该是这样的:

[[[CCDirector sharedDirector]openGLView] addSubview: viewController.view]; 
[viewController presentModalViewController: controller animated:YES];

关于ios - 新的 View Controller 出现然后消失在 CCScene 后面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4939928/

相关文章:

ios - Objective-C:从JSON获取图像

ios - 在其他 View iOS 中停止 AvAudioPlayer

ios - 错误表达式类型 '@lvalue String?' 在没有更多上下文的情况下不明确

ios - 呈现和关闭模态视图 Controller

iphone - 导航栏没有出现在我的 ViewController 上

iphone - 如何在同一层继承两个类?

ios - UIDocumentInteractionController 不打开应用程序 (didEndSendingToApplication : never called)

objective-c - Cocos2D无限背景图片

android - 进入后台时cocos2d-x游戏崩溃

ios - 解析推送通知,收到通知时如何修改当前 View Controller 中的变量?