UITableView に AdMob を実装する際に問題があります。さまざまな Web サイトからのニュース フィードを含む配列 (newsItems) があります。配列はニュースサイトの日付でソートされます。ニュースサイトをテーブルビューに表示したいのですが、アプリの無料版では、AdMob からの広告を 10 番目のテーブルビューセルごとに表示したいと考えています。
他の回答のコードを使用して、広告をテーブルビューに追加しました。
if (0 == (row % 10)) {
//cells with an add
static NSString *MyIdentifier;
NSInteger row = [indexPath row];
MyIdentifier = [NSString stringWithFormat:@"AdCell%d", row];
cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
}
[cell.contentView addSubview:[AdMobView requestAdWithDelegate:self]];
return cell;
} else {
// the code to create a standard cell (simplified)
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
NSString *cellValue = [newsItems objectAtIndex:indexPath.row];
cell.text = cellValue;
}
私はこれが正しくないことを知っています。「[newsItems objectAtIndex:indexPath.row]」を使用すると、配列を調べて一致する行のインデックスに newsitem を追加することで、テーブルにデータが入力されます。これは、add を行 10 に追加する必要がある場合、配列の行 10 にある対応する newsItem は無視されず、AdWhirl-ad によって上書きされないことを意味します。
代わりに、newsitem を広告の下の行に追加したいと考えています。これは可能ですか?