Thursday, October 20, 2011

ios AdMob

// Create a view of the standard size at the bottom of the screen.

GADRequest *request = [GADRequest request];

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){

bannerView_ = [[GADBannerView alloc]

initWithFrame:CGRectMake(20.0,

self.view.frame.size.height -

GAD_SIZE_728x90.height,

GAD_SIZE_728x90.width,

GAD_SIZE_728x90.height)];

}

else{

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 = @"ADMOBID";

// 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_];

[
self.view bringSubviewToFront:bannerView_];

// Initiate a generic request to load it with an ad.

[bannerView_ loadRequest:request];

No comments: