在ios 7中添加从底部显示的栏

时间:2013-10-22 05:42:42

标签: 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]];

}

2 个答案:

答案 0 :(得分:3)

如果您正在以编程方式进行操作那么您首先需要为iOS 6设置正确的baneerview位置,然后检测其iOS 6或iOs 7是否其iOS 7然后其Y坐标应(Y坐标)在iOS 6)+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 = @"********";
    }

答案 1 :(得分:0)

我做到了

if ([[[UIDevice currentDevice] systemVersion] integerValue] < 6)
{

 bannerView = [[GADBannerView alloc]
                  initWithFrame:CGRectMake(128.0,
                                           670 ,
                                           GAD_SIZE_728x90.width,
                                           GAD_SIZE_728x90.height)];
    bannerView.adUnitID = @"********";


}
else

{

 bannerView = [[GADBannerView alloc]
                  initWithFrame:CGRectMake(128.0,
                                           678 ,
                                           GAD_SIZE_728x90.width,
                                           GAD_SIZE_728x90.height)];
    bannerView.adUnitID = @"********";


}