ios - 在 ios 7 中添加显示窗体底部的栏

标签 ios ios7

我在我的应用程序底部显示添加,但在 iOS 7 中,添加从底部显示,但在 iOS 6 中,添加显示在底部。

enter image description here

-(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/

相关文章:

ios - ios - 如何在ios swift中使用自动布局以编程方式将两个标签并排放置在中心和间距?

ios - 如何获取包含字典的数组

ios - 7.1 以下的 iOS 版本中未显示 UITextView

ios7 - iOS企业应用程序后台下载或上传时间限制

ios - 更改 CGRect 然后单击文本字段返回到原始位置

ios - 呈现 UIImagePickerController 会导致 iOS 7 崩溃

ios - UIWebview 键盘返回键按下 ios 7

objective-c - UIView 仅设置侧边框

ios - iOS GameCenter GKErrorCanceled

ios - 将多行文本放入动态改变大小的节点