views:

44

answers:

1

I've spent too much time walking down dead ends on this project, so it's time to query the hive mind:

I am making a simple iPad game consisting of three locations which the user navigates between when an area of the screen is touched. These locations are represented by fullscreen images and there are a lot of different animations and stuff going on which makes it logical to divide each location into its own UIViewController.

The question is this: Which components should I use for handling the navigation between the locations/controllers?

UITabbarController: After finally managing to hide it away without a white bar at the bottom, I could not get selectedIndex to work in order to swap between view controllers.

UINavigationController: Does not permit more than one view controller inside, and I have three which I want to use. Is it possible to hide it away and still use it?

I could of course cram all my logic into a single UIViewController, but this seems plain wrong. Any advice or solutions for a newbie struggling towards journeymanhood would be greatly appreciated indeed!

A: 

If I well understand, everything happens like if you had three view to manage separately. If this is the case, you definitely should have three view controller. Communication between these controllers should then take place in the model. View controllers can be made aware of changes in the model through delegate in this case. If those interaction become too heavy, I suggest you create a super controller (application controller) managing the model and the three controllers.

VdesmedT
Sounds good, but how can I hand the control over the UI to another view controller without using a navigationcontroller or tabbarcontroller?
thomax
Of course, its then up to the applicationController (lets called it that way) to place, position or remove the views in the window. I suggest that the applicationController communicates only with the viewControllers and not with their views. You will then create methods in the viewControllers to manipulate their views. (better use [leftViewController moveView:newFrame] than leftViewController.view.frame = newFrame) just so your controllers keeps controls over what happening to their views.
VdesmedT
Thanks for helping me out on this! But I'm still not quite catching on. In the setup you describe, I will have one implementation of touchesBegan in each viewController. But how do I set which viewController is the active one receiving the touches?
thomax
the touchesBegan is sent to the upFrontView positioned where the touch happend so you don't have to control that. Now if you want something to happen in you controller, you can use a delegate pattern to communicate between the view and the controller. I start feeling like I need more details on what you are doing...
VdesmedT
I had another go after thinking more about this. I'm going to settle for a single UIViewController with three separate sub-controllers doing stuff on their locations behalf. I think I have it all drawn up nicely and confidence that it will work. Thanks for you time and insight :-)
thomax