In one of my ViewControllers I have the following code:
- (void)viewDidLoad
{
UITabBarController *tabBarController = (UITabBarController*)[UIApplication sharedApplication].keyWindow.rootViewController ;
[tabBarController setDelegate:self];
}
and :
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController: (UIViewController*)viewController {
NSLog(@"Yup!");
}
Whenever I switch tabs in my multi-tab setup, the console spits out
Yup
just as expected.
However, when I add
UITabBarController *tabController = (UITabBarController*)self.window.rootViewController;
tabController.selectedIndex = 1;
to my AppDelegate.m's
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
the 'Yup' doesn't show anymore.
How come?