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];
                Working sample copy is here:
For using: [AdMobViewController createBanner:self];
#import "AdMobViewController.h"
#import "GADBannerView.h"
@interface AdMobViewController ()
@end
@implementation AdMobViewController
static GADBannerView *bannerView;
static UIView *senderView;
static UIView *containerView;
static UIView *bannerContainerView;
static float bannerHeight;
+ (void)createBanner:(UIViewController *)sender
{
    if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone)
    {
        bannerHeight = 50;
    }
    else
    {
        bannerHeight = 90;
    }
    GADRequest *request = [GADRequest request];
    request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
    bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
    bannerView.adUnitID = @"ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx";
    bannerView.rootViewController = (id)self;
    bannerView.delegate = (id<GADBannerViewDelegate>)self;
    senderView = sender.view;
    bannerView.frame = CGRectMake(0, 0, senderView.frame.size.width, bannerHeight);
    [bannerView loadRequest:request];
    containerView = [[UIView alloc] initWithFrame:senderView.frame];
    bannerContainerView = [[UIView alloc] initWithFrame:CGRectMake(0, senderView.frame.size.height, senderView.frame.size.width, bannerHeight)];
    for (id object in sender.view.subviews) {
        [object removeFromSuperview];
        [containerView addSubview:object];
    }
    [senderView addSubview:containerView];
    [senderView addSubview:bannerContainerView];
}
+ (void)adViewDidReceiveAd:(GADBannerView *)view
{
    [UIView animateWithDuration:0.5 animations:^{
        containerView.frame = CGRectMake(0, 0, senderView.frame.size.width, senderView.frame.size.height - bannerHeight);
        bannerContainerView.frame = CGRectMake(0, senderView.frame.size.height - bannerHeight, senderView.frame.size.width, bannerHeight);
        [bannerContainerView addSubview:bannerView];
    }];
}
@end
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With