1

I try to integrate iAd to my App.

I have a class SwitchViewController (: UIViewController) which deals with all the custom ViewControllers & Views I have in this app.

When adding the View as below at the highest atIndex, I get an error:

ADBannerView: WARNING A banner view has an ad but may be obscured

However, if I do not insert all the other subviews - the iAd works fine. I can see it, but of course all the other views are gone.

Any Ideas?

Adding the subview by:

ADBannerView *tmpBannerView = [[ADBannerView alloc] initWithFrame:CGRectZero];
self.adView_iPad = tmpBannerView;
self.adView_iPad.frame = CGRectMake(0, 0, self.adView_iPad.frame.size.width, self.adView_iPad.frame.size.height);
self.adView_iPad.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifierPortrait];
self.adView_iPad.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
self.adView_iPad.delegate = self;
[self.view insertSubview:self.adView_iPad atIndex:100];
4

1 回答 1

0

You always want to make sure the ADBannerView is the topmost view in the hierarchy to avoid this warning. If any view overlaps it, even if it has transparency, you'll get this warning.

You can simply do something like this.

ADBannerView *adView = <create the view>;
[superView addSubview:adView];
[superView bringSubviewToFront:adView];

UPDATE:

When setting the view size, it is best to query the class for the size.

+ (CGSize)sizeFromBannerContentSizeIdentifier:(NSString *)contentSizeIdentifier

This will return the height and width that you should use. So set the frame like this:

CGSize size = [ADBannerView sizeFromBannerContentSizeIdentifier: ADBannerContentSizeIdentifierPortrait];
self.adView_iPad.frame = CGRectMake(0, 0, size.width, size.height);
于 2011-10-25T15:31:14.610 回答