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-14-2010, 11:36 AM   #6 (permalink)
tsansone
Registered Member
 
Join Date: Feb 2010
Posts: 11
Default

Quote:
Originally Posted by hstaniloff View Post
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
Hello, I am very new at developing for the iphone but have managed to get the AdMob code working in my normal views. But a portion of my app is in Tables. When I add the code to the tables it does work but the first record is always cut off. I tried using your method from above, but I think some steps were left out.

I am getting the following errors after using your code:

error: 'adMobAd' undeclared (first used in this function)
error: 'AdMobView' undeclared (first used in this function)
error: request for member 'tableView' in something not a structure or union.

Any help would be appreciated.. Baby steps would help too

Thanks
tsansone is offline   Reply With Quote
 

» Advertisements
» Online Users: 373
17 members and 356 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:01 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.