你好朋友我在我的项目中使用cocos2d和viewcontroller。首先加载我的应用程序,第一次cocos2d场景加载成功。之后我推动那个场景来查看控制器它也工作得很好。但是当我再次推到现场时我有错误,因为不支持多次推送相同的视图控制器实例。我尝试更多但没有得到任何解决方案。< / p>
我的代码如下
director_将app推送到场景
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
navController_ = [[MyNavigationController alloc] initWithRootViewController:director_];
}
我将场景推送到viewconreoller,如下所示
-(void)SceneToController
{
ViewController *yourViewController = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
[[CCDirector sharedDirector].navigationController pushViewController:yourViewController animated:YES];
}
我成功地来到了viewcontroller
在我将viewController推送到场景后如下面的代码
-(void)ViewToScene
{
AppController *app = (AppController*) [[UIApplication sharedApplication] delegate];
director_ = (CCDirectorIOS*) [CCDirector sharedDirector];
[director_ pushScene:[NewLayer scene]];
[[app navController] pushViewController:director_ animated:YES];
}
但它有错误,因为不支持多次推送相同的视图控制器实例。请帮助我吧