managing views for a single tab bar item

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

  1. macrumors regular

    Joined:
    Aug 28, 2008
    #1
    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. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    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. macrumors member

    davedelong

    Joined:
    Sep 9, 2007
    Location:
    Right here.
    #3
    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:

    Code:
    [[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
     
  4. thread starter macrumors regular

    Joined:
    Aug 28, 2008
    #4
    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. macrumors 68040

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

Share This Page