Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add AdMob ads to a UITableView

I am trying to add an AdMob ad to a table view.

I would like it to show up in every 10th cell. (Eg. like how it is in the Free version of the Reddit App if you have it).

I tried to follow the AdMob documentation but I didn't have any luck and I'm sure there is something I am missing.

Could anyone shine some light on a simple way to do this? Thanks!

like image 322
JordanC Avatar asked Oct 18 '09 00:10

JordanC


1 Answers

I've used code basically like this:

int row = [indexpath row];

if (0 == (row % 10)) {  // or 9 == if you don't want the first cell to be an ad!
    static NSString *MyIdentifier = @"AdCell";
    cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
    }
    [cell.contentView addSubview:[AdMobView requestAdWithDelegate:self]];
} else {
     // make your normal cells
}
like image 115
David Maymudes Avatar answered Sep 20 '22 11:09

David Maymudes