Michael Rowe
Michael Rowe

Reputation: 956

How do I position AdMob ad above the Tabbar?

I've gotten the latest version of the iOS code for AdMob. It is working fine, but the ad shows up under the tabbar I have. How do I move the ad up above the bar? Here's my relevant code:

#import "InformationViewController.h"


@implementation InformationViewController

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
    // Create a view of the standard size at the bottom of the screen.

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
    {
        /* run something specific for the iPad */
        bannerView_ = [[GADBannerView alloc]
                       initWithFrame:CGRectMake(0.0,
                                                self.view.frame.size.height -
                                                GAD_SIZE_300x250.height,
                                                GAD_SIZE_300x250.width,
                                                GAD_SIZE_300x250.height)];
    } 
    else
    {
        /* run something specific for the iPhone */
        bannerView_ = [[GADBannerView alloc]
                       initWithFrame:CGRectMake(0.0,
                                                self.view.frame.size.height -
                                                GAD_SIZE_320x50.height,
                                                GAD_SIZE_320x50.width,
                                                GAD_SIZE_320x50.height)];
    }

    // Specify the ad's "unit identifier." This is your AdMob Publisher ID.
    bannerView_.adUnitID = MY_BANNER_UNIT_ID;

    // Let the runtime know which UIViewController to restore after taking
    // the user wherever the ad goes and add it to the view hierarchy.
    bannerView_.rootViewController = self;
    [self.view addSubview:bannerView_];

    // Initiate a generic request to load it with an ad.
    [bannerView_ loadRequest:[GADRequest request]];
}

And my header file -

#import "GADBannerView.h"

#import <UIKit/UIKit.h>


@interface InformationViewController : UIViewController {

    GADBannerView *bannerView_;

}

@end

Upvotes: 1

Views: 5000

Answers (1)

ecd
ecd

Reputation: 36

You can try this;

bannerView_ = [[GADBannerView alloc]
                       initWithFrame:CGRectMake(0.0,
                                                100.0 -
                                                GAD_SIZE_320x50.height,
                                                GAD_SIZE_320x50.width,
                                                GAD_SIZE_320x50.height)];

use any other number below of 100 to move the banner up. Hope this work for you!

Upvotes: 2

Related Questions