Guest User

Untitled

a guest
Jun 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. - (void)viewWillDisappear:(BOOL)animated {
  2. [super viewWillDisappear:animated];
  3.  
  4. // This is to clean up from the colored bar in detail view
  5. self.navigationController.navigationBar.tintColor = nil;
  6.  
  7. // These are to match the behaviour of Contacts app
  8. [self setEditing:NO animated:NO];
  9.  
  10. // This is the tricky part: works when switching tabs, but not when back button was going to pop anyway!!
  11. [self.navigationController popToViewController:rootViewControllerForTab animated:NO];
  12. }
  13.  
  14. @interface Pop2RootTabSwitchAppDelegate : NSObject
  15. <UIApplicationDelegate, UITabBarControllerDelegate> {
  16. UINavigationController *tab1NavController;
  17. }
  18. @property (nonatomic, retain) IBOutlet UINavigationController *tab1NavController;
  19. @end
  20.  
  21. @implementation Pop2RootTabSwitchAppDelegate
  22.  
  23. - (void)tabBarController:(UITabBarController *)tabBarController
  24. didSelectViewController:(UIViewController *)viewController {
  25. NSLog(@"[%@ tabBarController:%@ didSelectViewController:%@]", [self class],
  26. tabBarController, viewController);
  27. if (viewController == tab1NavController) {
  28. NSLog(@"viewController == tab1NavController");
  29. [tab1NavController popToRootViewControllerAnimated:NO];
  30. }
  31. }
Add Comment
Please, Sign In to add comment