Adds Bar showing up form Bottom in ios 7

会有一股神秘感。 提交于 2019-12-11 05:59:05

问题


I am showing adds at the bottom of my app, but in iOS 7, adds are showing up from the bottom, but in iOS 6 adds are showing at the bottom.

-(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]];

}

回答1:


If you are doing it Programmatically Then you first need to set up the correct position of baneerview for iOS 6, then detect if its iOS 6 Or iOs 7 if its iOS 7 then its Y coordinate should be (Y coordinate In iOS 6) +20.

You should add 20px because iOS 7 takes the status bar as inside the view controller.

Try this it should work. According to your answer it should be

    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 = @"********";
    }



回答2:


I have done it

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 = @"********";


}


来源:https://stackoverflow.com/questions/19509830/adds-bar-showing-up-form-bottom-in-ios-7

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!