Skip to content

Instantly share code, notes, and snippets.

@nowherenearithaca
Created February 22, 2013 15:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nowherenearithaca/5014255 to your computer and use it in GitHub Desktop.
Save nowherenearithaca/5014255 to your computer and use it in GitHub Desktop.
Snippet for putting the iAd at the TOP of the screen rather than the bottom in a PhoneGap app; this is a slight tweak of the code in Scott DeSapio's note: http://engineering.scottdesapio.com/2013/02/add-iad-to-phonegap-application.html
- (void)webViewDidFinishLoad:(UIWebView*)theWebView
{
// Black base color for background matches the native apps
theWebView.backgroundColor = [UIColor blackColor];
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
CGRect adFrame = adView.frame;
if([UIApplication sharedApplication].statusBarOrientation
== UIInterfaceOrientationPortrait
|| [UIApplication sharedApplication].statusBarOrientation
== UIInterfaceOrientationPortraitUpsideDown) {
adView.currentContentSizeIdentifier =
ADBannerContentSizeIdentifierPortrait;
adFrame.origin.y = 0;
//resize the webview below it - bfl
theWebView.frame = CGRectMake(0, adView.frame.size.height,
theWebView.frame.size.width,
self.view.frame.size.height-adView.frame.size.height);
//adFrame.origin.y = self.view.frame.size.height-adView.frame.size.height;
} else {
adView.currentContentSizeIdentifier =
ADBannerContentSizeIdentifierLandscape;
adFrame.size.width = adView.frame.size.width;
adFrame.origin.y = 0;
theWebView.frame = CGRectMake(0, adView.frame.size.height,
theWebView.frame.size.width,
self.view.frame.size.height-adView.frame.size.height);
//adFrame.origin.y = self.view.frame.size.width-adView.frame.size.height;
}
adView.frame = adFrame;
[self.view addSubview:adView];
return [super webViewDidFinishLoad:theWebView];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment