PDA

View Full Version : managing views for a single tab bar item




arnieterm
Aug 28, 2008, 10:51 AM
There is a tabbarcontroller with four tabs. For the first tab with its view there is a button on whose click i want to show another view where the user makes some selections and then click a button to come to previous view
How this can be done?
Any idea?



robbieduncan
Aug 28, 2008, 10:56 AM
Sounds like you want a navigation controller. That would allow you to push the second view, get a nice slide right transition and you get the back button for free...

davedelong
Aug 28, 2008, 11:18 AM
You can do this with a TabBarController, too.

When you set up your TabBarController, the various sub-ViewControllers are stored in an array (0-based, of course). If you have four ViewControllers, and you're on the second one and you want to switch to the third one, I believe you can do:

[[self parentViewController] setSelectedIndex:3];

This is untested, but it should work.

However, ask yourself: Is this really the design paradigm that I want? TabBars are for separating sections of your application by functionality. Take a look at the Clock app. A world clock has a different purpose than an Alarm clock, which are both different from stopwatches and timers. Hence, it's a TabBar.

Contrast this with the Calendar application, where things are done with a NavigationController. This is because the logic flows from one section to the next. Tapping the "Add" button brings up a screen that present a visual logic flow. It's something that would clearly not work as well with a TabBarController.

HTH,

Dave

arnieterm
Aug 28, 2008, 11:49 PM
My app requirement does not include a navigation controller. Also for the first tab, I want to show another view where after entering some values the user will click a button which will bring him to the previous view

admanimal
Aug 29, 2008, 12:05 AM
My app requirement does not include a navigation controller. Also for the first tab, I want to show another view where after entering some values the user will click a button which will bring him to the previous view

That is what you would normally use a navigation controller for.