iphoneios5admobxcode4.3adwhirl

AdMob Error - Must set the rootViewController property of GADBannerView before calling loadRequest:


I am trying to set up a simple single-view iOS5 iPhone application (with AppDelegates, ViewControllers and a MainStoryboard) with AdWhirl (including the support files - AdWhirl, GoogleAdMobAdsSDK & TouchJSON) installed - only using iAds & AdMob. At this point there is nothing else in the app. This would be used for myself in future apps as a starting template.

I have followed a few different tutorials to try and figure out how to set this up since I am just learning to program myself. I have gotten the iAds to show and work fine and the iAds do register views in AdWhirl, so they seem to be working correctly. But I get this error in the log when trying to call an AdMob ad:

Must set the rootViewController property of GADBannerView before calling loadRequest:

I have searched and found answers that are above my knowledge at this point. Can some explain what I would need to do and where I would need to do it to fix this error? I would think that I would need to alter the "GADBannerView.h" file in the "GoogleAdMobAdsSDK" which I have tried to do, but unsuccessfully so far.

If there are any other questions, or if you would like to look at the project files or code (like I said there is nothing else in the app so far), just let me know.

Any help would be greatly appreciated.


Solution

  • Well, I finally figured it out. For anyone else with this error, this is how I solved it.

    In the "ViewController.m" file, I changed the following code, and now both iAds & AdMob ads show fine without errors.

    - (UIViewController *)viewControllerForPresentingModalView {
        //return UIWindow.viewController;
        return [(AppDelegate *)[[UIApplication sharedApplication] delegate] viewController];
    }
    

    to: 

    - (UIViewController *)viewControllerForPresentingModalView {
        //return UIWindow.viewController;
        return self;
    }