This solution is for iOS 6
Use notifications to listen for a device orientation change in the viewDidLoad method of your view controller:
UIDevice *device = [UIDevice currentDevice];
[device beginGeneratingDeviceOrientationNotifications];
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserver:self selector:@selector(orientationChanged:)name:UIDeviceOrientationDidChangeNotification object:device];
UIInterfaceOrientation destOrientation = self.interfaceOrientation;
Then use an if statement in your viewController to listen for the change, and reposition the Ad Banner View when the orientation changes:
if (destOrientation == UIInterfaceOrientationPortrait || destOrientation == UIInterfaceOrientationPortraitUpsideDown) {
ADBannerView *bannerView = (ADBannerView *)[self.view viewWithTag:615];
CGRect myAdBanner = bnrAd.frame;
myAdBanner.origin.x = 0;
myAdBanner.origin.y = 410;
bannerView.frame = myAdBanner;
} else {
ADBannerView *bannerView = (ADBannerView *)[self.view viewWithTag:615];
CGRect myAdBanner = bnrAd.frame;
myAdBanner.origin.x = 0;
myAdBanner.origin.y = 265;
bannerView.frame = myAdBanner;
}
Don't forget to call the methods to load the ad into your view:
- (void) bannerViewDidLoadAd:(ADBannerView *)banner {
bnrAd = _bannerView;
}
- (BOOL) bannerViewActionShouldBegin:(ADBannerView *)banner willLeaveApplication:(BOOL)willLeave {
return YES;
}