6

テーブル ビューに AdMob 広告を追加しようとしています。

10 番目のセルごとに表示されるようにします。(たとえば、Reddit アプリの無料版がある場合のように)。

AdMob のドキュメントに従おうとしましたが、うまくいきませんでした。何か不足していると確信しています。

誰かがこれを行う簡単な方法に光を当てることができますか? ありがとう!

4

1 に答える 1

15

私は基本的に次のようなコードを使用しました:

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
}
于 2009-10-18T01:47:33.963 に答える