0
votes

I'm using AdWhirl to display both iAd and AdMob ads in my app. On the iPad, when in Landscape orientation, I create an AdWhirlView that is 1024 wide, but the first iAd returned is always a Portrait width ad (768). If I rotate the iPad to portrait and then back to landscape, then the ad is properly shown 1024 wide in full landscape.

Why won't the landscape ads show to start without the need for rotation?

- (void) setupAdWhirl {
    if (self.adWhirlView == nil) {
        CGFloat adWhirlHeight = 90.0;

        CGSize size = self.rootViewController.view.bounds.size;
        NSLog(@"rootVC.bounds=%@", NSStringFromCGRect(self.rootViewController.view.bounds));

        AdWhirlView *adWhirl = [AdWhirlView requestAdWhirlViewWithDelegate:self];
        adWhirl.frame = CGRectMake(0, size.height - adWhirlHeight, size.width, adWhirlHeight);
        adWhirl.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin;
        NSLog(@"adWhirl.frame=%@", NSStringFromCGRect(adWhirl.frame));

        [self.rootViewController.view addSubview:adWhirl];
        self.adWhirlView = adWhirl;
    }
}

Those two log statements output the following:

rootVC.bounds={{0, 0}, {1024, 748}}
adWhirl.frame={{0, 658}, {1024, 90}}

So the frame I'm setting initially on the adWhirlView is 1024 wide and 90 tall. However, when it loads the first iAd, it resizes to 768 wide.

1

1 Answers

0
votes

I don't know if there was a "proper" way to do this, but I hacked the AdWhirl source and managed to get it working as I expect.

In the iAd adapter, -getAd method, after the creation of the ADBannerView, I added the following code:

  iAdView = [[ADBannerView alloc] initWithAdType:ADAdTypeBanner];
  iAdView.autoresizingMask = UIViewAutoresizingFlexibleWidth;

  // Added lines below

  if (self.adWhirlView.bounds.size.width > self.adWhirlView.bounds.size.height) {
      iAdView.currentContentSizeIdentifier = kADBannerContentSizeIdentifierLandscape;
  }
  else {
      iAdView.currentContentSizeIdentifier = kADBannerContentSizeIdentifierPortrait;
  }