简体   繁体   中英

my admob banner shows in top

I have a admob banner in my app and I've implemented it with the documentation AdMob provided, the only thing wrong with it is that it does not show at the bottom of the screen but in the top instead. Now I've been looking for a long time But I can't find how to change it and I can't find anyone one the net solving this problem.

Someone knows how to fix this?

Thanks

EDIT

// Create a view of the standard size at the bottom of the screen.
// Available AdSize constants are explained in GADAdSize.h.
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = @"MYID";    
// 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]];

been looking for numbers on all the admob scripts but Can't find any to edit..

Have you tried changing the frame of the view (GADBannerView I think?) to position it at the bottom instead of the top?

Here's an example (you should replace the placeholders with the correct attributes: bannerView.frame = CGRectMake(0.0, 460 - bannerheight , bannerwidth , bannerheight );


edit:

All you need to do is replace this:

bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];

With all of this:

// Initialize the banner at the bottom of the screen.
CGPoint origin = CGPointMake(0.0,
                               self.view.frame.size.height -
                               CGSizeFromGADAdSize(kGADAdSizeBanner).height);

// Use predefined GADAdSize constants to define the GADBannerView.
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
                                                  origin:origin];
CGFloat height = [UIScreen mainScreen].bounds.size.height;

bannerView_=[[GADBannerView alloc] initWithAdSize:(kGADAdSizeBanner) origin:CGPointMake(0,height-kGADAdSizeBanner.size.height)];
CGPoint origin = CGPointMake(0.0,bannerHeight);
self.addBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait
                                             origin:origin];

this for all iphones and iPads

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM