1

I am trying to add the Ads from google Admob, I have gone through the documentation and found that we can set the custom size for the ads banner. I have done it in this way

    int Ad_y;
    int iphone_5Hgt = 548;
    int iphoneHgt   = 460;
    int ipadHgt     = 748;
    int widthHere;
    int hgtHere;
    if (!IS_IPad)
    {
        if (IS_IPHONE_5 || IS_HEIGHT_GTE_568)
        {
            Ad_y = iphone_5Hgt-50;
        }
        else
        {
            Ad_y = iphoneHgt-50;
        }
        widthHere = 320;
        hgtHere = 50;
    }
    else
    {
        Ad_y = ipadHgt - 110;
        widthHere = 703;
        hgtHere = 90;
    }

   AdMob = [[GADBannerView alloc]
              initWithFrame:CGRectMake(0.0,
                                      Ad_y,
                                      widthHere,
                                      hgtHere)];
    if (!IS_IPad)
    {
      [AdMob setAdSize:kGADAdSizeBanner];
    }
    else
    {
        [AdMob setAdSize:GADAdSizeFromCGSize(CGSizeMake(widthHere, hgtHere))];
    }

    AdMob.delegate = self;
    AdMob.rootViewController = self;
    AdMob.adUnitID = AdMob_ID;     
    GADRequest *request = [[GADRequest alloc] init];
    request.testing = NO;

    [AdMob loadRequest:request];
    [self.view addSubview:adMob];

So, in in iPad with split view controller in landscape mode the size of Detail page is 703 so, i Set it [AdMob setAdSize:GADAdSizeFromCGSize(CGSizeMake(widthHere, hgtHere))]; But when i receive the Ads from google some ads are of size less then the specified size. Text ads are of proper size and fits properly, it fits the specified rect on landscape mode of Detail page. but the ads with Image (i.e banner) are sometimes not fits the rect. here is the example here the banner sticks to left corner of adMobBannerView and size is less then the required ad size. my questions is: is there any way to show only ads whose size fit the specified rect. OR can I set the center of the received Ads so it can be adjusted properly.

Bhavin Kansagara
  • 2,866
  • 1
  • 16
  • 20

0 Answers0