Skip to content
Browse files

Fix for 4.2 changes. Frames vs Bounds and all that. Ads are clickable…

… again. ( more to come for orientation changes )
  • Loading branch information...
1 parent 6068c7a commit 72a32e52c5b0e6934422bb1c0921a459ac518d0e Jesse committed Feb 24, 2011
Showing with 49 additions and 36 deletions.
  1. +49 −36 iPhone/AdPlugin/SAiOSAdPlugin.m
View
85 iPhone/AdPlugin/SAiOSAdPlugin.m
@@ -56,19 +56,11 @@ - (void) __prepare:(BOOL)atBottom
Class adBannerViewClass = NSClassFromString(@"ADBannerView");
if (adBannerViewClass && !self.adView)
{
- self.adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
- self.adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifier320x50, ADBannerContentSizeIdentifier480x32, nil];
- self.adView.delegate = self;
-
- CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
- if (atBottom) {
- CGRect adViewFrame = self.adView.frame;
- adViewFrame.origin.y = [UIScreen mainScreen].bounds.size.height - statusBarHeight - adViewFrame.size.height;
- self.adView.frame = adViewFrame;
-
- self.bannerIsAtBottom = YES;
- }
-
+ adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
+ adView.requiredContentSizeIdentifiers = [NSSet setWithObjects: ADBannerContentSizeIdentifierPortrait, ADBannerContentSizeIdentifierLandscape, nil];
+ adView.delegate = self;
+
+ self.bannerIsAtBottom = atBottom;
self.bannerIsVisible = NO;
self.bannerIsInitialized = YES;
}
@@ -90,55 +82,76 @@ - (void) __showAd:(BOOL)show
return;
}
- CGRect adViewFrame = self.adView.frame;
- CGRect webViewFrame = [super webView].frame;
- CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
+ CGRect adViewFrame = adView.frame;
+ CGRect webViewFrame = webView.frame;
+ CGRect screenFrame = [ [ UIScreen mainScreen ] applicationFrame ];
+
+ //CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
+
+ [UIView beginAnimations:@"blah" context:NULL];
+ [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
if (show)
{
- if (self.bannerIsAtBottom)
+// CGFloat bannerHeight = 0.0;
+//
+// // First, setup the banner's content size and adjustment based on the current orientation
+// if(UIInterfaceOrientationIsLandscape(self.appViewController.interfaceOrientation))
+// {
+// adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
+// bannerHeight = 32.0;
+// }
+// else
+// {
+// adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
+// bannerHeight = 50.0;
+// }
+
+ adViewFrame.size.width = screenFrame.size.width;
+
+ if (self.bannerIsAtBottom)
{
- webViewFrame.size.height -= (adViewFrame.size.height + statusBarHeight);
+ adViewFrame.origin.y = screenFrame.size.height - adViewFrame.size.height;
+
+ self.adView.frame = adViewFrame;
+
}
- else
+ else // aka: at the top
{
webViewFrame.origin.y += adViewFrame.size.height;
- webViewFrame.size.height -= (adViewFrame.size.height + statusBarHeight);
}
- [UIView beginAnimations:@"blah" context:NULL];
- [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
-
- [super webView].frame = webViewFrame;
- [[[super webView] superview] addSubview:self.adView];
- [UIView commitAnimations];
+ webViewFrame.size.height -= adViewFrame.size.height;
+ webView.frame = webViewFrame;
+ [ webView.superview addSubview:self.adView];
+
self.bannerIsVisible = YES;
}
else
{
- if (self.bannerIsAtBottom)
+ if (self.bannerIsAtBottom)
{
- webViewFrame.size.height += (adViewFrame.size.height + statusBarHeight);
+
}
- else
+ else // aka: at the top
{
- webViewFrame.origin.y -= adViewFrame.size.height;
- webViewFrame.size.height += (adViewFrame.size.height + statusBarHeight);
+ webViewFrame.origin.y = screenFrame.origin.y;
}
+
- [UIView beginAnimations:@"blah" context:NULL];
- [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
+ webViewFrame.size.height += adViewFrame.size.height;
- [super webView].frame = webViewFrame;
- [self.adView removeFromSuperview];
+ webView.frame = webViewFrame;
+ [ adView removeFromSuperview];
- [UIView commitAnimations];
self.bannerIsVisible = NO;
}
+ [UIView commitAnimations];
+
}
#pragma mark -

0 comments on commit 72a32e5

Please sign in to comment.
Something went wrong with that request. Please try again.