Search code examples
iphoneobjective-carchitectureuiviewcontrolleruitabview

iphone tab app architecture question


I have two tabs on my app that handle different flows.

For each tab I want to have a controller that determines (based on info in the app) which view to display.

So you click on tab 1, the app goes through some logic and displays either View B or View C. From there I use a navigation controller to go to other views within that tab.

To handle the initial logic of figuring out which view (B or C) to display I have a view controller (View A) linked to the tab that handles all the logic. My issue is that if I click on tab 1 while I'm already "on" the tab it displays the view for View A, which is a blank page.

Does anyone have an idea of how to architect this or make it so the view for View A is never displayed?


Solution

  • UITabBarControllerDelegate

    in your implementation of:

    tabBarController:shouldSelectViewController:
    

    you should try to detect if you are already on the first tab or not. if so just return NO and it won't pop to the root controller (in this case A)