1

Let me make the question more clear.

I have tab bar application with navigation controller included in each tab.

When click the tab 2 i go to login screen. From login screen i navigate to next screen (say screen 2) using login button. When i am on screen 2 if i cilck the tab 2 i again go to login screen. I do not want this. I want application to remain at same screen even if tab 2 is clicked again.

If i cilck any other tab in between then it works as expected.

How to achieve this??

Aditya Athavale
  • 183
  • 3
  • 12
  • 1
    possible duplicate of [Disable action - user taps on tabbar item to go to root view controller](http://stackoverflow.com/questions/4191504/disable-action-user-taps-on-tabbar-item-to-go-to-root-view-controller) – lxt Aug 11 '11 at 12:31

2 Answers2

1
- (BOOL)tabBarController:(UITabBarController *)tabBarController 
    shouldSelectViewController:(UIViewController *)viewController {

   if ([tabBarController.selectedViewController isEqual:viewController])
      return NO;
   }
   return YES;
}

Alternatively, you can catch taps on the tab bar and check if the selectedIndex changed or not.

Mundi
  • 79,884
  • 17
  • 117
  • 140
0

The UITabBarController will pop to the root view controller if you tap a tab that you are currently displaying. To prevent this behavior take a look at this question:

Disable action - user taps on tabbar item to go to root view controller

Community
  • 1
  • 1
lxt
  • 31,146
  • 5
  • 78
  • 83