我在我的应用程序底部显示添加,但在 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 将状态栏作为 View Controller 内部。
试试这个应该可以的。
根据你的回答应该是
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 = @"********";
}
关于ios - 在 ios 7 中添加显示窗体底部的栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19509830/