Hi
I am trying to implement AdMob Ads into my iOS app. I've having trouble however, as the two photos will show the app working in both landscape and portrait mode. In portrait, the advert is aligned fine, however when in landscape the advert sticks to the left. I was this advert centred, and this becomes a bigger problem when I add them to the iPad. Please see screenshots attached for what is happening.
My code in SafariViewController.h is:
And then I have tried two bits of code in my SafariViewController.m:
AND
Basically I am looking for a method of aligning my advert block in the middle of the screen, whether in portrait or landscape orientation. I was wondering if I could like this somehow to a view which I could then position correctly in the interface builder?
Any help much appreciated - I'm new to objective C so basic rather than advance if possible please.
Thanks in advance
Sam
I am trying to implement AdMob Ads into my iOS app. I've having trouble however, as the two photos will show the app working in both landscape and portrait mode. In portrait, the advert is aligned fine, however when in landscape the advert sticks to the left. I was this advert centred, and this becomes a bigger problem when I add them to the iPad. Please see screenshots attached for what is happening.
My code in SafariViewController.h is:
Code:
...
@interface SafariViewController : UIViewController {
GADBannerView *bannerView_;
}
@end
And then I have tried two bits of code in my SafariViewController.m:
Code:
// Create a view of the standard size at the bottom of the screen.
bannerView_ = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0,
self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
// Specify the ad's "unit identifier." This is your AdMob Publisher ID.
bannerView_.adUnitID = @"a14e8cb1e3bff49";
// 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]];
AND
Code:
// Place an ad at the top of the screen of an iPhone/iPod Touch.
CGRect adFrame = CGRectZero;
adFrame.size = GAD_SIZE_320x50;
// Create and setup the ad view.
GADBannerView *adView = [[GADBannerView alloc] initWithFrame:adFrame];
adView.rootViewController = self;
adView.adUnitID = @"a14e8cb1e3bff49";
// Place the ad view onto the screen.
[self.view addSubview:adView];
[adView release];
// Request an ad without any additional targeting information.
[adView loadRequest:nil];
Basically I am looking for a method of aligning my advert block in the middle of the screen, whether in portrait or landscape orientation. I was wondering if I could like this somehow to a view which I could then position correctly in the interface builder?
Any help much appreciated - I'm new to objective C so basic rather than advance if possible please.
Thanks in advance
Sam