views:

434

answers:

2

My question starts from a problem :

I started a project in XCode : a Navigation Bar based one (with a TableView). Then I added a few views, through IB or programmatically... which works perfectly fine. Then, I decided to write my Own ViewClass, inherited from UIView, called OpenGlView (based on the view provided by Basic OpenGlES project in XCode), and its OpenGlViewController (inherited from UIViewController).

This works fine until I try to push the view Controller into my navBar: then I receive a "EXC__ BAD __ACCESS". I can't understand why it is ok whith any View but the one used for display OpenGL content... And I actually have no idea how I can manage to develop a NavBar based App including a View displaying OpenGl contents... any idea?

(I also tried to add the OpenGlView as a subView of a basic UIView previously added to the NavigationBar, but I received the same error).

In the RootController :

 OpenGlViewController *glvController;

...

if (glvController == nil) 
 {
  glvController = [[OpenGlViewController alloc] initWithNibName:@"Gl View" bundle:nil];
  glvController.title = @"GL View";
 }
[self.navigationController pushViewController:glvController animated:YES];

in the OpenGlViewController :

- (void)loadView {
OpenGlView * view;
view = [[OpenGlView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view = view;
[view release];

}

A: 

If it's localized to your OpenGL view, the crash may be the result of not properly initializing OpenGL items inside your view. See here for my recommendations on a potentially similar problem.

Brad Larson
A: 

Thanks for your help.

Actually, this is the same as yours (but for the test on USE_DEPTH_BUFFER).

I was then wondering if I could really add any custom ViewController to a NavigationBarController of if it must be a "ViewController" (not one inherited from)?

Gael LE BELLEGO
Any UIViewController subclass can be pushed onto the UINavigationController's stack (not the UINavigationBar, that's just the control element at the top of the screen).
Brad Larson