I created a class as AdMobViewController and I use to add banner this class. Banner create but other objects in view don't scroll up. How I do programmatically scroll up all objects in view.
My AdMobViewController class and method:
+ (void)createBanner:(UIViewController *)sender
{
GADRequest *request = [GADRequest request];
request.testing = YES;
request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
GADBannerView *bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView.adUnitID = @"ca-app-pub-123456";
bannerView.rootViewController = (id)self;
bannerView.delegate = (id<GADBannerViewDelegate>)self;
bannerView.frame = CGRectMake(0, 518, 320, 50);
[bannerView loadRequest:request];
[sender.view addSubview:bannerView];
}
And I use for creating banner:
[AdMobViewController createBanner:self];
Inside the delegate callback
adViewDidReceiveAd:
, check the size of the ad and move your views accordinglyThis is an aside, because my problem looked similar, but was not.
App ID is NOT the same as Ad Unit ID.
And, stupidly, they BOTH start with ca-app-pub- and a lot of numbers. I was using the App ID which I can guarantee 100% does NOT work.
Yes, I feel pretty silly, but the folks at Google should have made them dissimilar.
However, if you use the Ad Unit ID, surprisingly, everything works. :)
This worked for me:
Working sample copy is here:
For using: [AdMobViewController createBanner:self];
Well I think you have multiple things to consider:
[sender.view addSubview:bannerView]
does not move other views, instead you are placing the banner view directly on top of the view hierarchy.Ads are loaded asynchronously, so you should implement the delegate methods of
GADBannerView
for showing and hiding the ad view.If you really want to move other views around you should use some kind of container view to include all other content except your banner. If you receive an ad you can easily move the container view (or shrink it) and display your banner view on some location in your main view.
Cheers