How to place admob banner at the bottom of the screen in the iOS retina and not the retina

I created a phonegap application and want to add an Admob banner to it. I have a banner running at the bottom of the screen in the iOS6 simulator, but when I test it on the retina device, the banner will go from the bottom, as if it is still trying to display the screen for non-retina display. Here is my current code in viewDidLoad:

// Initialize the banner at the bottom of the screen. CGPoint origin = CGPointMake(0.0, self.view.frame.size.height - CGSizeFromGADAdSize(kGADAdSizeBanner).height); // Use predefined GADAdSize constants to define the GADBannerView. bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner origin:origin]; // Specify the ad "unit identifier." This is your AdMob Publisher ID. bannerView_.adUnitID = @"xxxxxxxxxxxx"; // Let the runtime know which UIViewController to restore after taking // the user wherever the ad goes and add it to the view hierarchy. bannerView_.rootViewController = self; [self.view addSubview:bannerView_]; // Initiate a generic request to load it with an ad. [bannerView_ loadRequest:[GADRequest request]]; 
+6
source share
4 answers

I solved this by moving the above code from viewDidLoad to webViewDidFinishLoad .

+4
source

You can try this,

 bannerView_ = [[GADBannerView alloc] initWithFrame:CGRectMake(0.0, self.view.frame.size.height-GAD_SIZE_320x50.height, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)]; 
+6
source

I used this code to count for the NavigationBar and status bar:

 CGPoint origin = CGPointMake(0.0, self.view.frame.size.height - CGSizeFromGADAdSize(kGADAdSizeBanner).height - self.navigationController.navigationBar.frame.size.height - 20 /* status bar */); 
+1
source

I have not tested your code, so it may already work, but using non-origin initialization and source reset later works:

 bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner]; // Omitted: set up ad id, etc CGRect frame = bannerView_.frame; frame.origin.y = self.view.frame.size.height - frame.size.height; bannerView_.frame = frame; [self.view addSubview:bannerView_]; 
0
source

All Articles