Search code examples
objective-cadmobcocos2d-xiadcocos2d-x-3.0

Integrating iAd with AdMob displays only black screen


I am facing issues while combining iAd and Admob in Cocos2d 3.0. The whole screen goes black.

I have created a view controller which handles loading of iAd and Admob. Here is my code on pastie.org, I believe required steps to integrate iAd and Admob are known to users reading the question.

BannerViewController.h http://pastie.org/9926394

BannerViewController.m http://pastie.org/9926406

Assume following things are defined in AppDelegate.h

#define        isLite     1
#define     iADLoaded   1

To use the Ad view controller in GameScene I write following code block:

#ifdef isLite
    bannerViewC = [[BannerViewController alloc] initWithContentViewController: [CCDirector sharedDirector]];
    [[[[CCDirector sharedDirector] view] window] setRootViewController: bannerViewC];
    [bannerViewC showBanner];
#endif

bannerViewC is defined in CCScene.h on which we are going to display the advertise.

The problem: The problem is when I tried to load iAd the device screen goes black. Means, when iAdLoaded is 1 the problem occur and if we remove this define statement from delegate means don't define iAdLoaded, the controller loads AdMob perfectly. The problem is iAd only, I can't figure out why iAd usage turns the whole screen black.

If someone has time to look into this. Your help is appreciated.


Solution

  • Like to answer my own question :).

    If anybody faces the issue, mine was resolved by just changing one line of code.

    I have used ADAdTypeBanner rather than ADBannerView *banner = [[ADBannerView alloc] initWithFrame: rect]; (rect). Means removing the line which specifies rect for the add was causing the issue.