0
votes

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
1
You usually get this sort of error when you have not included a needed framework to your project.Groot
If you post the error we could tell you if it's a missing framework and which one you need?FractalDoctor

1 Answers

0
votes

You can check out the latest AdMob sample projects here.

If you're using the latest AdMob SDK, you only need the ObjC linker flag; you no longer need -all_load.

EDIT:

If you are using libraries that still require the -all_load flag, you can instead pass -force_load path/to/library.a to load only that library.