我在应用程序的底部显示添加,但是在iOS 7中,添加从底部显示,但是在iOS 6中,添加在底部显示。
-(void)showAdds
{
[bannerView removeFromSuperview];
if ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad))
{
// bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(128.0,
670 ,
GAD_SIZE_728x90.width,
GAD_SIZE_728x90.height)];
bannerView.adUnitID = @"********";
}
else {
// Create a view of the standard size at the bottom of the screen.
// bannerView = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(80,
250,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
bannerView.adUnitID = @"*******";
NSLog(@"ads");
}
bannerView.rootViewController = self;
[self.view addSubview:bannerView];
// Initiate a generic request to load it with an ad.
[bannerView loadRequest:[GADRequest request]];
}
如果您以编程方式进行操作,则首先需要为iOS 6设置baneerview的正确位置,然后检测其iOS 6或iOs 7(如果其iOS 7),则其Y坐标应为(iOS 6中的Y坐标)+20 。
您应该添加20px,因为iOS 7将状态栏作为视图控制器的内部。
试试这个,它应该可以工作。根据您的回答应该是
if ([[[UIDevice currentDevice] systemVersion] integerValue] < 7)
{
bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(128.0,
670 ,// Replace it with 650
GAD_SIZE_728x90.width,
GAD_SIZE_728x90.height)];
bannerView.adUnitID = @"********";
}
else
{
bannerView = [[GADBannerView alloc]
initWithFrame:CGRectMake(128.0,
690 ,// Replace it with 670 if upper value is replaced with 650
GAD_SIZE_728x90.width,
GAD_SIZE_728x90.height)];
bannerView.adUnitID = @"********";
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句