Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-04-2010, 08:14 AM   #5 (permalink)
hstaniloff
Registered Member
 
Join Date: Apr 2009
Location: Setauket, NY
Posts: 133
Lightbulb AdMob ads in a TableViewHeader

Quote:
Originally Posted by swizzy View Post
Hi, I have the exact same problem, can you please share the steps that fixed it?
In my opinion, putting ads at the very top or the very bottom breaks the look and feel of the iPhone interface. I just don't like the way it looks. Take a peek at weather.com app and you'll see what I mean.
Since almost all of my view controllers are tables, I decided to display the ads in a TableViewHeader. It looks good and the user can scroll it away if the display is big enough - I sort of like that behavior.
So here's what I did to implement it:
In my view controller's viewDidLoad I have the following:
Code:
if (tableHeaderView == nil) {
	CGRect frameRectangle = CGRectMake(0.0f, 0.0f, 320.0f, 48.0f);
	tableHeaderView = [[UIView alloc] initWithFrame:frameRectangle];
	tableHeaderView.backgroundColor = [UIColor colorWithRed:0.208 green:0.435 blue:0.659 alpha:1];
        self.tableView.tableHeaderView = tableHeaderView;
    }

// Request an ad
adMobAd = [AdMobView requestAdWithDelegate:self];
[adMobAd retain]; // this will be released when it loads (or fails to load)
tableHeaderView is defined as a UIView in my .h file. Then, I do the following assignment in the AdMob callback didReceiveAd;
Code:
- (void)didReceiveAd:(AdMobView *)adView {
	NSLog(@"AdMob: Did receive ad");
		
	[self.tableView.tableHeaderView addSubview:adMobAd];
	[refreshTimer invalidate];
	refreshTimer = [NSTimer scheduledTimerWithTimeInterval:AD_REFRESH_PERIOD target:self selector:@selector(refreshAd:) userInfo:nil repeats:YES];
}
So that's how I implemented AdMob ads in my app. Hope that helps!
/H
hstaniloff is offline   Reply With Quote
 

» Advertisements
» Online Users: 377
17 members and 360 guests
acegames, ADY, BdR, catedawn, ChenXin, ckgni, Darmanikles, dfvdan, fkmtc, gagack, iph_s, MarkC, RoryHarvey, technovelty, thebinaryfamily, zacharyse, zbynda
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,874
Threads: 89,225
Posts: 380,698
Top Poster: BrianSlick (7,129)
Welcome to our newest member, catedawn
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:00 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.