Berendschot
Berendschot

Reputation: 3114

Admob won't load ads

I'm not getting any error or something.

I created a CustomView file, but it doesn't seem to work.

//CustomView.h
#import "GADBannerView.h"

@interface CustomView : UIView
{
    GADBannerView *bannerView_;

}

Second file:

//CustomView.m
bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, 430, 320, 50)];

bannerView_.adUnitID = MY_BANNER_UNIT_ID;
bannerView_.rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
NSLog(@"%@",bannerView_.rootViewController);
[self addSubview:bannerView_];


GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects: GAD_SIMULATOR_ID, nil];
[bannerView_ loadRequest:request];

Upvotes: 1

Views: 589

Answers (3)

Jack
Jack

Reputation: 16865

As per the documentation, you should allocate your banner like this:

[[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];

With the size you need, of course :)

Upvotes: 3

Berendschot
Berendschot

Reputation: 3114

As @JackWu said, I need to use:

[[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait];

Upvotes: 0

John Green
John Green

Reputation: 504

    GADRequest.isTesting = YES;

should be set.

Also, are there any messages in your Xcode Console?

Upvotes: 0

Related Questions