managing views for a single tab bar item

Discussion in 'iOS Programming' started by arnieterm, Aug 28, 2008.

  1. arnieterm macrumors regular

    Aug 28, 2008
    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?
  2. robbieduncan Moderator emeritus


    Jul 24, 2002
    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...
  3. davedelong macrumors member


    Sep 9, 2007
    Right here.
    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.


  4. arnieterm thread starter macrumors regular

    Aug 28, 2008
    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
  5. admanimal macrumors 68040

    Apr 22, 2005
    That is what you would normally use a navigation controller for.

Share This Page