Iphone 从OpenGL视图加载UIView

Iphone 从OpenGL视图加载UIView,iphone,uiview,opengl-es,Iphone,Uiview,Opengl Es,我对iPhone编程是新手,事实上,我对任何类型的编程都是新手。近一年来,我一直在自学C,然后是Objective-C,在过去的几个月里,我一直在制作一款iPhone游戏,到目前为止,我对此感到非常自豪 不管怎么说,我遇到了一个很大的绊脚石,我一直在努力想办法解决这个问题,但我做不到,如果有人能给我指出正确的方向,我将不胜感激 基本上,当应用程序启动时,它会加载到UIView中,这有点像菜单系统,带有“加载游戏”、“查看高分”等选项。当按下“加载游戏”时,会创建一个OpenGL视图,然后开始玩我

我对iPhone编程是新手,事实上,我对任何类型的编程都是新手。近一年来,我一直在自学C,然后是Objective-C,在过去的几个月里,我一直在制作一款iPhone游戏,到目前为止,我对此感到非常自豪

不管怎么说,我遇到了一个很大的绊脚石,我一直在努力想办法解决这个问题,但我做不到,如果有人能给我指出正确的方向,我将不胜感激

基本上,当应用程序启动时,它会加载到UIView中,这有点像菜单系统,带有“加载游戏”、“查看高分”等选项。当按下“加载游戏”时,会创建一个OpenGL视图,然后开始玩我的游戏。当游戏中的宇宙飞船撞上一颗行星时,游戏就要结束了,另一个UIView将显示高分并提供重试选项。我已经试着让这个UIView交换了一段时间,但它似乎不起作用。这些代码都能正确编译,没有错误或警告,但当宇宙飞船撞上行星时,什么也没发生。OpenGL视图保持为主视图,并且不会加载其他视图

下面是我的RootViewController类的代码,当按下“load game”(加载游戏)时调用DreamView,当宇宙飞船坠毁时调用newPage:

- (IBAction)drawEAGLView:(id)sender { //This code is called when "Load Game" is pressed in the first UIView.

 //This function contains the loading code of the OpenGl view, and seems to work well.

 BBSceneController * sceneController = [BBSceneController sharedSceneController];

 // make a new input view controller, and save it as an instance variable
 BBInputViewController * anInputController = [[BBInputViewController alloc] initWithNibName:nil bundle:nil];
 sceneController.inputController = anInputController;
 [anInputController release];
 // init our main EAGLView with the same bounds as the window
 EAGLView * glView = [[EAGLView alloc] initWithFrame:window.bounds];
 sceneController.inputController.view = glView;
 sceneController.openGLView = glView;
 self.view = glView;
 [glView release];

 glView.alpha = 0.0;

 [UIView beginAnimations:@"fadeout" context:nil];
 [UIView setAnimationDuration:0.5f];
 [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
 [UIView setAnimationDelegate:self];
 // Change any animatable properties here
 glView.alpha = 1.0;
 [UIView commitAnimations];


 // set our view as the first window view
 [window addSubview:sceneController.inputController.view];
 [window makeKeyAndVisible];



 // begin the game.
 [sceneController loadScene];
 [sceneController startScene];


}

- (void)newPage //This code is run when the spaceship crashes into the planet.
{

 NSLog(@"ViewTwoLoaded"); //This is logged in the console, which proves the code is being run.

 if(self.viewTwoController == nil)
 {
  ViewTwoController *viewTwo = [[ViewTwoController alloc]
           initWithNibName:@"View2" bundle:[NSBundle mainBundle]]; //View2 is the nib i want to load, but does not load.
  self.viewTwoController = viewTwo;
  [viewTwo release];
 }


 [self.navigationController pushViewController:self.viewTwoController animated:YES];

}
多年来,我一直在谷歌搜索和论坛搜索,但(可能是因为我不知道确切的正确术语),我什么也找不到

我已经尽力提供尽可能多的信息,任何帮助都将不胜感激

提前感谢,,
克雷格

你确定你在导航控制器中吗?对于OpenGL游戏来说似乎有点奇怪。如果将最后一行替换为:

[self presentModalViewController:self.viewTwoController animated:YES];
还有一些其他的事情你正在做,我不认为你需要像分配glView给三个属性那样

您也可以将视图添加到窗口中,就像您为glView所做的那样:

[window addSubview:self.viewTwoController.view];
或者甚至可以替换视图

self.view = self.viewTwoController.view;