Created
February 22, 2013 15:34
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (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