views:

442

answers:

2

Here is my code stub for my app-delegate.m -- it never gets called.

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    NSLog(@"%s", __FUNCTION__);
}

It is defined in this app-delegate.h

@interface OrioleAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
    UIWindow *window;
    UITabBarController *tabBarController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;

@end
A: 

I added the following tabBarController.delegate = self; and all is well. I hope this is helpful to others.

- (void)applicationDidFinishLaunching:(UIApplication *)application {

    // Add the tab bar controller's current view as a subview of the window
    tabBarController.delegate = self;
    [window addSubview:tabBarController.view];
}
mobibob
I am facing the same problem, I made sure that I have delegate set up as:tabBarController.delegate = self;but still the delegate methods are not being called.
Vibhor Goyal
check for conflicts from your IB definition. what class are you defining in the builder and is it hooked up to your cod correctly?
mobibob
A: 

Did you make a connection between your UITabBarController and your application delegate?

- (void)applicationDidFinishLaunching:(UIApplication *)application
{
     ...
     tabBarController.delegate = self;
     ...
}
Shaggy Frog
Yup -- I forgot and you were too quick :)) Thanks for the super-light-speed response.
mobibob