我的admob横幅显示在顶部
我在我的应用程序中有一个admob横幅,我已经使用AdMob提供的文档实现了它,唯一的问题是它不显示在屏幕的底部,而是显示在顶部。 现在我一直在寻找很长一段时间,但我找不到如何改变它,我找不到任何人解决这个问题。
有人知道如何解决这个问题?
谢谢
编辑
// 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]];
一直在寻找所有的admob脚本的数字,但找不到任何编辑..
你有没有尝试改变视图的框架(GADBannerView我认为?)将其放置在底部而不是顶部?
这是一个例子(你应该用正确的属性replace占位符:bannerView.frame = CGRectMake( bannerheight
– bannerheight
, bannerwidth
, bannerheight
);
编辑:
所有你需要做的是取代这个:
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
与所有这一切:
// 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];
这为所有的iPhone和iPad