Quote:
Originally Posted by swizzy
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