- didSelectViewController in AppDelegate is not called
- #import "AppDelegate.h"
- @interface AppDelegate()
- @property (nonatomic, retain) ADBannerView *bannerView;
- @property (nonatomic, assign) UIViewController<BannerViewContainer> *currentController;
- @end
- @implementation AppDelegate
- @synthesize window = _window;
- @synthesize bannerView;
- @synthesize currentController;
- - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- {
- // Override point for customization after application launch
- CGRect screenBounds = [[UIScreen mainScreen] bounds];
- // bannerView was here
- // This is the reference to the tab bar controller and first tab from storyboard.
- UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
- self.currentController = [[tabController viewControllers] objectAtIndex:0];
- NSLog(@"Root: %@", self.window.rootViewController);
- NSLog(@"Tab with banner: %@", self.currentController);
- return YES;
- }
- //and this isn't called:
- - (void)tabController:(UITabBarController *)tabController didSelectViewController:
- (UIViewController *)viewController
- {
- // If called for selection of the same tab, do nothing
- if (currentController == viewController) {
- return;
- }
- if (bannerView.bannerLoaded) {
- // If we have a bannerView atm, tell old view controller to hide and new to show.
- [currentController hideBannerView:bannerView];
- [(UIViewController<BannerViewContainer>*)viewController showBannerView:bannerView];
- }
- // And remember this viewcontroller for the future.
- self.currentController = (UIViewController<BannerViewContainer> *)viewController;
- }
- // This is the reference to the tab bar controller and first tab from storyboard.
- UITabBarController *tabController = (UITabBarController *)self.window.rootViewController;
- tabController.delegate = self;