I have a Universal app (iPhone/iPad) testing on IOS4.3. It has an iAd which I want to position at the bottom of the screen in both the orientations..
Below is the code;
- (void) viewWillAppear:(BOOL)animated {
adView_.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil];
adView_.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
CGRect adFrame = adView_.frame;
adFrame.origin.y = self.view.frame.size.height-adView_.frame.size.height;
adView_.frame = adFrame;
adView_.delegate = self;
[webView addSubview:adView_];
[self.view bringSubviewToFront:adView_];
self.bannerIsVisible=NO;
[super viewWillAppear: animated];
}
Now for orienation handling, I have;
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation))
self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
else
self.adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
CGRect adFrame = adView_.frame;
adFrame.origin.y = self.view.frame.size.height-adView_.frame.size.height;
adView_.frame = adFrame;
[webView addSubview:adView_];
[self.view bringSubviewToFront:adView_];
self.bannerIsVisible=NO;
}
My issue is on app load (portrait), I am able to see the iAd clearly positioned at screen bottom.
But as soon as I change orientation to landscape, I cannot see the iAd. I see the message;
ADBannerView: WARNING A banner view (0x62534a0) has an ad but may be
obscured. This message is only printed once per banner view.
I guess I am doing something wrong inside willRotateToInterfaceOrientation
Please help me fix the issue.
Thank you.
Try moving your code to didRotateFromInterfaceOrientation. The new geometry is not set yet in willRotateToInterfaceOrientation.