my admob banner shows in top

2019-03-28 06:22发布

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..

3条回答
放我归山
2楼-- · 2019-03-28 07:04
CGPoint origin = CGPointMake(0.0,bannerHeight);
self.addBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait
                                             origin:origin];

this for all iphones and iPads

查看更多
聊天终结者
3楼-- · 2019-03-28 07:06
CGFloat height = [UIScreen mainScreen].bounds.size.height;

bannerView_=[[GADBannerView alloc] initWithAdSize:(kGADAdSizeBanner) origin:CGPointMake(0,height-kGADAdSizeBanner.size.height)];
查看更多
何必那么认真
4楼-- · 2019-03-28 07:07

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];
查看更多
登录 后发表回答