@@ -56,19 +56,11 @@ - (void) __prepare:(BOOL)atBottom
5656 Class adBannerViewClass = NSClassFromString (@" ADBannerView" );
5757 if (adBannerViewClass && !self.adView )
5858 {
59- self.adView = [[ADBannerView alloc ] initWithFrame: CGRectZero];
60- self.adView .requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifier320x50, ADBannerContentSizeIdentifier480x32, nil ];
61- self.adView .delegate = self;
62-
63- CGFloat statusBarHeight = [UIApplication sharedApplication ].statusBarFrame .size .height ;
64- if (atBottom) {
65- CGRect adViewFrame = self.adView .frame ;
66- adViewFrame.origin .y = [UIScreen mainScreen ].bounds .size .height - statusBarHeight - adViewFrame.size .height ;
67- self.adView .frame = adViewFrame;
68-
69- self.bannerIsAtBottom = YES ;
70- }
71-
59+ adView = [[ADBannerView alloc ] initWithFrame: CGRectZero];
60+ adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil ];
61+ adView.delegate = self;
62+
63+ self.bannerIsAtBottom = atBottom;
7264 self.bannerIsVisible = NO ;
7365 self.bannerIsInitialized = YES ;
7466 }
@@ -90,55 +82,76 @@ - (void) __showAd:(BOOL)show
9082 return ;
9183 }
9284
93- CGRect adViewFrame = self.adView .frame ;
94- CGRect webViewFrame = [super webView ].frame ;
95- CGFloat statusBarHeight = [UIApplication sharedApplication ].statusBarFrame .size .height ;
85+ CGRect adViewFrame = adView.frame ;
86+ CGRect webViewFrame = webView.frame ;
87+ CGRect screenFrame = [ [ UIScreen mainScreen ] applicationFrame ];
88+
89+ // CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
90+
91+ [UIView beginAnimations: @" blah" context: NULL ];
92+ [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
9693
9794 if (show)
9895 {
99- if (self.bannerIsAtBottom )
96+ // CGFloat bannerHeight = 0.0;
97+ //
98+ // // First, setup the banner's content size and adjustment based on the current orientation
99+ // if(UIInterfaceOrientationIsLandscape(self.appViewController.interfaceOrientation))
100+ // {
101+ // adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
102+ // bannerHeight = 32.0;
103+ // }
104+ // else
105+ // {
106+ // adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
107+ // bannerHeight = 50.0;
108+ // }
109+
110+ adViewFrame.size .width = screenFrame.size .width ;
111+
112+ if (self.bannerIsAtBottom )
100113 {
101- webViewFrame.size .height -= (adViewFrame.size .height + statusBarHeight);
114+ adViewFrame.origin .y = screenFrame.size .height - adViewFrame.size .height ;
115+
116+ self.adView .frame = adViewFrame;
117+
102118 }
103- else
119+ else // aka: at the top
104120 {
105121 webViewFrame.origin .y += adViewFrame.size .height ;
106- webViewFrame.size .height -= (adViewFrame.size .height + statusBarHeight);
107122 }
108123
109- [UIView beginAnimations: @" blah" context: NULL ];
110- [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
111-
112- [super webView ].frame = webViewFrame;
113- [[[super webView ] superview ] addSubview: self .adView];
114124
115- [UIView commitAnimations ] ;
125+ webViewFrame. size . height -= adViewFrame. size . height ;
116126
127+ webView.frame = webViewFrame;
128+ [ webView.superview addSubview: self .adView];
129+
117130 self.bannerIsVisible = YES ;
118131 }
119132 else
120133 {
121- if (self.bannerIsAtBottom )
134+ if (self.bannerIsAtBottom )
122135 {
123- webViewFrame. size . height += (adViewFrame. size . height + statusBarHeight);
136+
124137 }
125- else
138+ else // aka: at the top
126139 {
127- webViewFrame.origin .y -= adViewFrame.size .height ;
128- webViewFrame.size .height += (adViewFrame.size .height + statusBarHeight);
140+ webViewFrame.origin .y = screenFrame.origin .y ;
129141 }
142+
130143
131- [UIView beginAnimations: @" blah" context: NULL ];
132- [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
144+ webViewFrame.size .height += adViewFrame.size .height ;
133145
134- [ super webView ] .frame = webViewFrame;
135- [self . adView removeFromSuperview ];
146+ webView.frame = webViewFrame;
147+ [ adView removeFromSuperview ];
136148
137- [UIView commitAnimations ];
138149
139150 self.bannerIsVisible = NO ;
140151 }
141152
153+ [UIView commitAnimations ];
154+
142155}
143156
144157#pragma mark -
0 commit comments