views and OpenGL

Posts: 1
Joined: 2009.01
Post: #1
Hi Everyone,

This is my first post! I'm working on an iPhone game consisting of an OpenGL view and several canned views (for menus, help screens, etc).

I'm still a bit fuzzy about switching views and was hoping for some clarification from you guys. The example I'm working from is from the book 'Beginning iPhone Development' by Mark and LaMarche. The chapter I'm looking at is entitled "Multiview Applications".

The example consists of a main custom View Controller that contains two custom View Controllers, one for each 'screen' present in the example. These custom view controllers own a custom view, with each attached to a custom view NIB.

The main custom view controller is the class that has code to switch between the views of the two screen-specific view controllers. It also describes how to use UIView animations to transition between the two (which is a feature I want my project to have).

I'm looking at example and I can't help but think that there's an easier way to do it:

1) The example is limited to swapping between two screens. My game could have 5-6 screens. I suppose I can call 'release' on the view controllers I don't need, but I haven't been able to discern when would be a good time. At what point during the [UIView beginAnimations]...[UIView commitAnimations] can I release my reference to the old View object and therefore associated View Controller?
2) It seems like having a custom NIB, UIView, and UIViewController for each screen is overkill. I've tried to dynamically allocate a NIB-driven view with no luck. I first create a MyView that derives from UIView. I then create a View NIB, taking care to both a) set File's Owner to my class and b) set the 'Class' property of the View NIB to MyView. I then instantiate a MyView* in my app delegate and add it to my app window. However I always get a white screen regardless of what I put in the NIB. Shouldn't objects of type MyView now automatically load what's in the NIB? I just had a thought (but can't confirm in XCode right now): Does my MyView member in my delegate have to have the 'IBOutlet' declaration? Is that the missing link that tells it to load the right NIB?
3) I thought I had a third question but rather will save it for a rainy day

Thanks for your time everyone, any comments would be greatly appreciated. I'm a video game coder by profession but my work is higher-level and rarely gets platform-specific. This iPhone stuff is like greek to me. =)

Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Multiple XIB or Views Jerm #1 1 4,686 Feb 2, 2010 02:10 AM
Last Post: Newbrof
  Messaging between separate views Toontingy 0 3,039 Jan 9, 2010 05:10 PM
Last Post: Toontingy
  OpenGL ES 2d game - multiple EAGL Views or not? Elphaba 4 6,772 Aug 4, 2009 10:42 AM
Last Post: maximile
  Multiple OpenGL views tfifriday 2 4,925 Dec 28, 2008 02:51 PM
Last Post: tfifriday
  Maintain variables across multiple Views masumbuet 1 3,303 Dec 17, 2008 06:42 AM
Last Post: pierre