In this code i have added Google AdmobSDK in my Xcode project and tried to display an ad. But i am not quite sure if this code does really work!
AdmobiPhoneViewController.m
#import "AdmobiPhoneViewController.h"
#define AdMob_ID @"a151120ca07fb81"
@implementation AdmobiPhoneViewController
- (void)dealloc
{
AdMob.delegate = nil;
[AdMob release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
Releases the view if it doesn’t have a superview. [super didReceiveMemoryWarning];
Release any cached data, images, etc that aren’t in use. } #pragma mark – View lifecycle //Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
AdMob = [[GADBannerView alloc]
initWithFrame:CGRectMake(0.0, self.view.frame.size.height -
GAD_SIZE_320x50.height,
GAD_SIZE_320x50.width,
GAD_SIZE_320x50.height)];
AdMob.adUnitID = AdMob_ID;
AdMob.rootViewController = self;
[self.view addSubview:AdMob];
GADRequest *r = [[GADRequest alloc] init];
r.testing = YES;
[AdMob loadRequest:r];
}
- (void)viewDidUnload
{
[super viewDidUnload];
//Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
//Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
@end