Finally, I stumbled on a stackoverflow conversation. Without further ado...
Add the following line to your didFinishLaunchingWithOptions in AppDelegate:
[UIApplication sharedApplication].idleTimerDisabled = YES;
Notes-to-self and other scattered ramblings about writing code and drinking lots of coffee.
[UIApplication sharedApplication].idleTimerDisabled = YES;
#import <iAd/iAd.h>
@interface MainViewController : CDVViewController {
ADBannerView *adView;
}
[adView release];
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
CGRect adFrame = adView.frame;
if([UIApplication sharedApplication].statusBarOrientation
== UIInterfaceOrientationPortrait
|| [UIApplication sharedApplication].statusBarOrientation
== UIInterfaceOrientationPortraitUpsideDown) {
adView.currentContentSizeIdentifier =
ADBannerContentSizeIdentifierPortrait;
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 = self.view.frame.size.width-adView.frame.size.height;
}
adView.frame = adFrame;
[self.view addSubview:adView];
BOOL hide = (newInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || newInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
[[UIApplication sharedApplication] setStatusBarHidden:hide withAnimation:UIStatusBarAnimationNone];
CGRect mainFrame = [[UIScreen mainScreen] applicationFrame];
[self.view setFrame:mainFrame];
if (newInterfaceOrientation != UIInterfaceOrientationLandscapeLeft && newInterfaceOrientation != UIInterfaceOrientationLandscapeRight) {
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierPortrait;
[self.view bringSubviewToFront:adView];
adView.frame = CGRectMake(0.0, self.view.frame.size.height - adView.frame.size.height, adView.frame.size.width, adView.frame.size.height);
}
else {
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifierLandscape;
[self.view bringSubviewToFront:adView];
adView.frame = CGRectMake(0.0, self.view.frame.size.width - adView.frame.size.height, adView.frame.size.width, adView.frame.size.height);
}