0

I've a problem that in my tabbarviewcontroller there are many viewcontroller in a particular tab button.I want that when I press tab button it should come first viewcontroller regarding that tab button not the current viewcontroller of that tab button. please some one help me.

User97693321
  • 3,336
  • 7
  • 45
  • 69
sandy
  • 23
  • 5
  • Can you clarify what you mean regarding making the tab button itself the first view controller? Here is a [tutorial](http://www.youtube.com/watch?v=LBnPfAtswgw) that gives a good example of combining a tab bar, navigation controller, and table view. You don't have to use all three, but it describes the main concepts of combining different view controllers. – Evan Johnson Jun 17 '11 at 05:00

1 Answers1

1

You cannot control this. TabBarController will always show the rootViewController corresponding to that tabBarButtonItem when you tapped the button again.

EDIT

Then read TabBar Delegate methods like tabbar didSelectItem it's something like that. Implement that delegate method like in appDelegate and then you can always check show view1 when that button index is tapped. Here is the method. You can get the index and pop the view2 so it will always view1 displayed.

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item; // called when a new view is selected by the user (but not programatically)
Rahul Vyas
  • 28,260
  • 49
  • 182
  • 256
  • 1
    No, you could subclass the UITableViewController and override the appropriate methods to change the selection automatically from tab to the other. (Well, you are right in that visually if tab A is selected then tab B's view controller must not be showing) However this would be terrible user experience. – Moshe Jun 17 '11 at 05:09
  • Thanx for your response but Actually suppose I'm in second tabbarcontroller say view1 and from view1 i go view2 which is also in same tabbarcontroller now when I go first tabbarcontroller and press second tabbarcontroller then view2 comes but I want view1 should come. please give me some idea. Thanx. – sandy Jun 17 '11 at 08:42