Permalink
Browse files

Pop to rootViewController if selected tabBarItem is selected again

  • Loading branch information...
1 parent 4c91ddf commit 2bf16d387fae88ccd1191f6d1f0589c9bdcade0d @myell0w myell0w committed May 4, 2012
Showing with 10 additions and 2 deletions.
  1. +10 −2 NGTabBarController/NGTabBarController.m
@@ -582,8 +582,16 @@ - (void)handleItemPressed:(id)sender {
NSInteger index = [self.tabBarItems indexOfObject:sender];
BOOL shouldSelect = [self delegatedDecisionIfWeShouldSelectViewController:[self.viewControllers objectAtIndex:index] atIndex:index];
- if (shouldSelect && index != self.selectedIndex) {
- self.selectedIndex = index;
+ if (shouldSelect) {
+ if (index != self.selectedIndex) {
+ self.selectedIndex = index;
+ } else {
+ if ([self.selectedViewController isKindOfClass:[UINavigationController class]]) {
+ UINavigationController *navigationController = (UINavigationController *)self.selectedViewController;
+
+ [navigationController popToRootViewControllerAnimated:YES];
+ }
+ }
}
}

0 comments on commit 2bf16d3

Please sign in to comment.