我正在努力整合 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/