adWhirl's actualadsize method does not return correct information

320 Views Asked by At

I am testing with this:

  CGSize adSize = [adWhirlView actualAdSize];
NSLog(@"ad size received: %f x %f",adSize.width, adSize.height);

However, the width that is returned is always the width of the device orientation, no matter what the ad actually looks like. This is primarily an issue with adMob because its ads may be much less than the device's width and thus appear as flush left instead of centered, even though the adsize returned above is actually showing the ads are supposed to be full width.

Anyone else encountered this and have a suggestion on how to deal with it? If you don't know an ad's actual width, you cannot really center it properly.

2

There are 2 best solutions below

1
On BEST ANSWER

I have the same problem. I have adWhirl with iAd & AdMob ads enabled and I made like this: ........

CGSize adSize = [adWhirlView actualAdSize];
 ......
if (adSize.height==50){
 // this is AdMob ad, change x position

 } else {
 // iAd ad, leave by default
 }
0
On

The problem is located in the AdMob adapter:

  // Set the frame for this view to match the bounds of the parent adWhirlView.
  GADBannerView *view =
  [[GADBannerView alloc] initWithFrame:adWhirlView.bounds];

This is a very lousy implementation since AdWhirl is lacking optional delegate methods here. Though this is pretty easy to fix. Simple use one of AdMobs banner sizes and everything will work:

  GADBannerView *view =
  //[[GADBannerView alloc] initWithFrame:adWhirlView.bounds];
[[GADBannerView alloc] initWithFrame:CGRectMake(0, 0, GAD_SIZE_468x60.width, GAD_SIZE_468x60.height)];

You probably want to fix colors too. There are two bugs concerning colors:

  • The AdMob adapter does use the proper delegate methods (adWhirlAdBackgroundColor,adWhirlTextColor). Although, he simply uses the background color for text.
  • If the color delegate methods are not implemented, the AdMob adapter does not fallback to the colors you defined in your config.

To fix this, simply locate the code related to colors (right at the beginning of getAd()) and replace it with:

  if ((value = [self delegateValueForSelector:
                      @selector(adWhirlAdBackgroundColor)])) {
    [additional setObject:[self hexStringFromUIColor:(UIColor *)value]
                  forKey:@"color_bg"];
  } else {
    [additional setObject:[self hexStringFromUIColor:adWhirlConfig.backgroundColor]
                     forKey:@"color_bg"];
  }

  if ((value = [self delegateValueForSelector:
                      @selector(adWhirlTextColor)])) {
    [additional setObject:[self hexStringFromUIColor:(UIColor *)value]
                   forKey:@"color_text"];
  } else {
    [additional setObject:[self hexStringFromUIColor:adWhirlConfig.textColor]
                     forKey:@"color_text"];
  }