views:

24

answers:

1

Hi,

I'm creating an iPad app based on a UINavigationController (with the bar hidden) so I can push and pop other viewControllers for navigation around the app. However, I am now wanting to add a section in which there are two viewControllers that I want to be able to switch between, so in other words they are side-by-side, rather than hierarchical.

Is it okay to use a UITabBarController for this? I am aware that on the iPhone it is recommended they are used only at the root level of the app, but since this is an iPad app I wondered if I could use it? Also, I guess I need to create an empty viewController, create a UITabBarController within it and set the delegate to it, then add the two viewControllers to it... So in effect I will have a viewController within another viewController, and when I have done that in the past the results have been very flaky.

Can I do it this way? The only other way I can think of doing it is to have two plan UIViews within a UIViewController, but that also means I shouldn't really put any business logic in them (bad MVC!), and not being able to will be a right pain in the a**.

Any ideas?

Thanks!

:-Joe

EDIT: I also need to be able to swipe-animate between the two VCs within the TabBarController, AND have a menubar over the top which doesn't animate... Can I do this?

+1  A: 

Sure.

I do this kind of thing all over the place in an app I'm working on. I actually have several different types of "toolbars" that can be optionally shown at different times.

What I do is create a "parent" member in my toolbar's class - and when a button is pressed, I have the toolbar call a method in the parent class to do whatever needs to be done - (i.e. display another view).

This avoids the whole mess of creating a view inside another view (or viewcontroller inside another viewcontroller - or whatever) - the toolbar can take the button hits, but all the views are opened by the root view/controller.

Hope this helps/makes sense!

Brad
Do you mean that you add a parent property to the UITabBarController? At the moment I've created a class which extends UITabBarController and put the business logic in that... Is that the correct way to do it? Can I set its delegate to itself? Thanks for the help :)
Joe
The prior - add (and set) a "parent" property - and make the calls to manipulate views through the *parent*.
Brad
ah okay, so you're talking about using the UITabBarController just for its graphical tabs, rather than the internal structure... I wanted to do it the other way round unfortunately... If I start manipulating views through the parent then I may as well not be using a UITabBarController. As it is, I couldn't get it to animate the way I wanted it to, so I'm back to two UIViews.
Joe