我确信这是一个简单的修复,但我似乎无法找到它。我有一个表视图,目前工作正常,设置为:
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
cell.textLabel.text = [creedsList objectAtIndex:row];
cell.imageView.image = [UIImage imageNamed:[creedsImages objectAtIndex:row]];
return cell;
Admob SDK说要添加这一行:
[cell.contentView addSubview:[AdMobView requestAdWithDelegate:self]];
然后它用广告填充每个单元格。有什么想法吗?
编辑: 我正在使用此代码填充:
NSUInteger row = [indexPath row];
cell.textLabel.text = [creedsList objectAtIndex:row];
答案 0 :(得分:0)
您希望仅对希望广告显示的特定行执行此操作。
因此,如果您只想在第一行显示,则可以执行类似
的操作static int adTag = 999; // Used for identifying whether cell already contains ad
UIView * adView = [cell.contentView viewWithTag:adTag];
if(row == 0 && !adView)
{
adView = [AdMobView requestAdWithDelegate:self];
adView.tag = adTag;
[cell.contentView addSubview:adView];
}
else if(row != 0 && adView)
{
// Must remove since cells are reused.
[adView removeFromSuperview];
}